CREATE TABLE IF NOT EXISTS domain_monitor.users (
    id SERIAL PRIMARY KEY,
    username VARCHAR NOT NULL UNIQUE,
    password_hash VARCHAR NOT NULL,
    is_active BOOLEAN DEFAULT true,
    created_at TIMESTAMPTZ DEFAULT NOW()
);

CREATE INDEX IF NOT EXISTS idx_users_username ON domain_monitor.users (username);

-- 默认管理员账号: admin / admin123
-- 密码使用 bcrypt 哈希
INSERT INTO domain_monitor.users (username, password_hash)
VALUES ('admin', '$2b$12$jZ4f6ZAa5b/LmOsbBieOBe9qE25R1klvyZ74jaFdtQsjNpYsDEU5C')
ON CONFLICT (username) DO NOTHING;
