-- name: CreateUser :one
INSERT INTO users (username, password_hash)
VALUES ($1, $2)
RETURNING *;

-- name: CreateAdmin :one
INSERT INTO users (username, password_hash, is_admin)
VALUES ($1, $2, true)
RETURNING *;

-- name: ListUsers :many
SELECT * FROM users
LIMIT $1 OFFSET $2;

-- name: ListAdmins :many
SELECT * FROM users
WHERE is_admin = true;

-- name: GetUserByID :one
SELECT * FROM users
WHERE id = $1 LIMIT 1;

-- name: GetUserByUsername :one
SELECT * FROM users
WHERE username = $1 LIMIT 1;

-- name: UpdatePassword :one
UPDATE users
SET password_hash = $2, updated_at = NOW()
WHERE id = $1
RETURNING *;

-- name: DeleteUser :exec
DELETE FROM users
WHERE id = $1;
