Drop one-shot tmp/axe scripts and agent i18n scratch so the Gitea tree is deployable.
25 lines
684 B
SQL
25 lines
684 B
SQL
-- name: CreateAPIKey :one
|
|
INSERT INTO api_keys (company_id, user_id, name, key_hash, key_prefix)
|
|
VALUES ($1, $2, $3, $4, $5)
|
|
RETURNING *;
|
|
|
|
-- name: ListAPIKeysByCompany :many
|
|
SELECT id, company_id, user_id, name, key_prefix, last_used_at, revoked_at, created_at, updated_at
|
|
FROM api_keys
|
|
WHERE company_id = $1 AND revoked_at IS NULL
|
|
ORDER BY created_at DESC;
|
|
|
|
-- name: GetAPIKeyByHash :one
|
|
SELECT * FROM api_keys
|
|
WHERE key_hash = $1 AND revoked_at IS NULL
|
|
LIMIT 1;
|
|
|
|
-- name: RevokeAPIKey :one
|
|
UPDATE api_keys
|
|
SET revoked_at = now(), updated_at = now()
|
|
WHERE id = $1 AND company_id = $2
|
|
RETURNING *;
|
|
|
|
-- name: TouchAPIKey :exec
|
|
UPDATE api_keys SET last_used_at = now() WHERE id = $1;
|