lockserver/db/queries/issued_codes.sql
2024-11-22 19:50:54 -08:00

17 lines
580 B
SQL

-- name: CreateIssuedCode :one
INSERT INTO issued_codes (name, code, start, end) VALUES (?, ?, ?, ?) RETURNING id;
-- name: DeleteIssuedCode :exec
DELETE FROM issued_codes WHERE id = ?;
-- name: AssignIssuedCodeSlot :exec
INSERT INTO issued_code_slots (issued_code, lock, slot) VALUES (?, ?, ?);
-- name: UnassignIssuedCodeSlot :exec
DELETE FROM issued_code_slots WHERE issued_code = ? AND lock = ?;
-- name: GetAllIssuedCodes :many
SELECT * FROM issued_codes;
-- name: GetActiveCodes :many
SELECT * FROM issued_codes WHERE start < datetime('now') AND end > datetime('now');