Regions are identified by id so organizations can reuse keys. Triggers keep agents in regions of the same owner and monitors in platform or own regions. Platform admins are a user flag. Refs #52 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
34 lines
1018 B
SQL
34 lines
1018 B
SQL
-- name: CreateUser :one
|
|
INSERT INTO users (email, display_name, password_hash, locale) VALUES ($1, $2, $3, $4)
|
|
RETURNING *;
|
|
|
|
-- name: GetUser :one
|
|
SELECT * FROM users WHERE id = $1;
|
|
|
|
-- name: GetUserByEmail :one
|
|
SELECT * FROM users WHERE email = $1;
|
|
|
|
-- name: AnyUserExists :one
|
|
SELECT EXISTS (SELECT 1 FROM users);
|
|
|
|
-- name: SetPasswordHash :exec
|
|
UPDATE users SET password_hash = $2, updated_at = now() WHERE id = $1;
|
|
|
|
-- name: EnableTOTP :exec
|
|
UPDATE users SET totp_secret = $2, totp_enabled_at = now(), updated_at = now() WHERE id = $1;
|
|
|
|
-- name: DisableTOTP :exec
|
|
UPDATE users SET totp_secret = NULL, totp_enabled_at = NULL, updated_at = now() WHERE id = $1;
|
|
|
|
-- name: DeleteUser :execrows
|
|
DELETE FROM users WHERE id = $1;
|
|
|
|
-- name: SetUserLocale :exec
|
|
UPDATE users SET locale = $2, updated_at = now() WHERE id = $1;
|
|
|
|
-- name: SetUserAdmin :execrows
|
|
UPDATE users SET is_admin = $2, updated_at = now() WHERE email = $1;
|
|
|
|
-- name: MakeAdmin :exec
|
|
UPDATE users SET is_admin = true, updated_at = now() WHERE id = $1;
|