Files
Memoh/db/queries/bind.sql
T
BBQ 06e8619a37 refactor(core): migrate channel identity and binding across app
Align channel identity and bind flow across backend and app-facing layers, including generated swagger artifacts and package lock updates while excluding docs content changes.
2026-02-11 14:51:58 +08:00

23 lines
915 B
SQL

-- name: CreateBindCode :one
INSERT INTO channel_identity_bind_codes (token, issued_by_user_id, platform, expires_at)
VALUES ($1, $2, $3, $4)
RETURNING id, token, issued_by_user_id, platform, expires_at, used_at, used_by_channel_identity_id, created_at;
-- name: GetBindCode :one
SELECT id, token, issued_by_user_id, platform, expires_at, used_at, used_by_channel_identity_id, created_at
FROM channel_identity_bind_codes
WHERE token = $1;
-- name: GetBindCodeForUpdate :one
SELECT id, token, issued_by_user_id, platform, expires_at, used_at, used_by_channel_identity_id, created_at
FROM channel_identity_bind_codes
WHERE token = $1
FOR UPDATE;
-- name: MarkBindCodeUsed :one
UPDATE channel_identity_bind_codes
SET used_at = now(), used_by_channel_identity_id = $2
WHERE id = $1
AND used_at IS NULL
RETURNING id, token, issued_by_user_id, platform, expires_at, used_at, used_by_channel_identity_id, created_at;