forked from coder/coder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcrypto_keys.sql
More file actions
50 lines (44 loc) · 934 Bytes
/
crypto_keys.sql
File metadata and controls
50 lines (44 loc) · 934 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
-- name: GetCryptoKeys :many
SELECT *
FROM crypto_keys
WHERE secret IS NOT NULL;
-- name: GetCryptoKeysByFeature :many
SELECT *
FROM crypto_keys
WHERE feature = $1
AND secret IS NOT NULL
ORDER BY sequence DESC;
-- name: GetLatestCryptoKeyByFeature :one
SELECT *
FROM crypto_keys
WHERE feature = $1
ORDER BY sequence DESC
LIMIT 1;
-- name: GetCryptoKeyByFeatureAndSequence :one
SELECT *
FROM crypto_keys
WHERE feature = $1
AND sequence = $2
AND secret IS NOT NULL;
-- name: DeleteCryptoKey :one
UPDATE crypto_keys
SET secret = NULL, secret_key_id = NULL
WHERE feature = $1 AND sequence = $2 RETURNING *;
-- name: InsertCryptoKey :one
INSERT INTO crypto_keys (
feature,
sequence,
secret,
starts_at,
secret_key_id
) VALUES (
$1,
$2,
$3,
$4,
$5
) RETURNING *;
-- name: UpdateCryptoKeyDeletesAt :one
UPDATE crypto_keys
SET deletes_at = $3
WHERE feature = $1 AND sequence = $2 RETURNING *;