Skip to content

Commit 5567bc7

Browse files
committed
fix migrations
1 parent 0969c5d commit 5567bc7

File tree

5 files changed

+63
-73
lines changed

5 files changed

+63
-73
lines changed

coderd/database/migrations/000262_site_to_crypto_key.up.sql

Lines changed: 0 additions & 52 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
-- Step 1: Remove the new entries from crypto_keys table
22
DELETE FROM crypto_keys
3-
WHERE feature IN ('workspace_apps_token', 'workspace_apps_api_key', 'tailnet_resume')
4-
AND sequence = 1;
3+
WHERE feature IN ('workspace_apps_token', 'workspace_apps_api_key');
54

6-
CREATE TYPE crypto_key_feature_old AS ENUM (
5+
CREATE TYPE old_crypto_key_feature AS ENUM (
76
'workspace_apps',
87
'oidc_convert',
98
'tailnet_resume'
109
);
1110

1211
ALTER TABLE crypto_keys
13-
ALTER COLUMN feature TYPE crypto_key_feature_old
14-
USING (feature::text::crypto_key_feature_old);
12+
ALTER COLUMN feature TYPE old_crypto_key_feature
13+
USING (feature::text::old_crypto_key_feature);
1514

1615
DROP TYPE crypto_key_feature;
1716

18-
ALTER TYPE crypto_key_feature_old RENAME TO crypto_key_feature;
17+
ALTER TYPE old_crypto_key_feature RENAME TO crypto_key_feature;
1918

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
-- Create a new enum type with the desired values
2+
CREATE TYPE new_crypto_key_feature AS ENUM (
3+
'workspace_apps_token',
4+
'workspace_apps_api_key',
5+
'oidc_convert',
6+
'tailnet_resume'
7+
);
8+
9+
DELETE FROM crypto_keys WHERE feature = 'workspace_apps';
10+
11+
-- Drop the old type and rename the new one
12+
ALTER TABLE crypto_keys
13+
ALTER COLUMN feature TYPE new_crypto_key_feature
14+
USING (feature::text::new_crypto_key_feature);
15+
16+
DROP TYPE crypto_key_feature;
17+
18+
ALTER TYPE new_crypto_key_feature RENAME TO crypto_key_feature;

coderd/database/migrations/testdata/fixtures/000262_site_to_crypto_key.up.sql

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
INSERT INTO crypto_keys (feature, sequence, secret, secret_key_id, starts_at, deletes_at)
2+
VALUES (
3+
'workspace_apps_token',
4+
1,
5+
'abc',
6+
NULL,
7+
'1970-01-01 00:00:00 UTC'::timestamptz,
8+
'2100-01-01 00:00:00 UTC'::timestamptz
9+
);
10+
11+
INSERT INTO crypto_keys (feature, sequence, secret, secret_key_id, starts_at, deletes_at)
12+
VALUES (
13+
'workspace_apps_api_key',
14+
1,
15+
'def',
16+
NULL,
17+
'1970-01-01 00:00:00 UTC'::timestamptz,
18+
'2100-01-01 00:00:00 UTC'::timestamptz
19+
);
20+
21+
INSERT INTO crypto_keys (feature, sequence, secret, secret_key_id, starts_at, deletes_at)
22+
VALUES (
23+
'oidc_convert',
24+
2,
25+
'ghi',
26+
NULL,
27+
'1970-01-01 00:00:00 UTC'::timestamptz,
28+
'2100-01-01 00:00:00 UTC'::timestamptz
29+
);
30+
31+
INSERT INTO crypto_keys (feature, sequence, secret, secret_key_id, starts_at, deletes_at)
32+
VALUES (
33+
'tailnet_resume',
34+
2,
35+
'jkl',
36+
NULL,
37+
'1970-01-01 00:00:00 UTC'::timestamptz,
38+
'2100-01-01 00:00:00 UTC'::timestamptz
39+
);
40+

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy