-- name: CreateUser :one
INSERT INTO users (oidc_subject, username, email)
VALUES (?, ?, ?)
RETURNING *;

-- name: GetUserByID :one
SELECT * FROM users
WHERE id = ?;

-- name: GetUserByOIDCSubject :one
SELECT * FROM users
WHERE oidc_subject = ?;

-- name: UpdateUser :one
UPDATE users
SET username = ?, email = ?
WHERE id = ?
RETURNING *;

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

-- name: ListUsers :many
SELECT * FROM users
ORDER BY username;

-- name: GetUserMembership :one
SELECT is_member, sites_quota FROM users
WHERE id = ?;

-- name: UpdateUserMembership :one
UPDATE users
SET is_member = ?, sites_quota = ?
WHERE id = ?
RETURNING *;

-- name: GetUserSitesQuota :one
SELECT sites_quota FROM users
WHERE id = ?;
