Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5567bc7

Browse files
committed
fix migrations
1 parent0969c5d commit5567bc7

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.
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
-- Step 1: Remove the new entries from crypto_keys table
22
DELETEFROM crypto_keys
3-
WHERE featureIN ('workspace_apps_token','workspace_apps_api_key','tailnet_resume')
4-
AND sequence=1;
3+
WHERE featureIN ('workspace_apps_token','workspace_apps_api_key');
54

6-
CREATETYPEcrypto_key_feature_oldAS ENUM (
5+
CREATETYPEold_crypto_key_featureAS ENUM (
76
'workspace_apps',
87
'oidc_convert',
98
'tailnet_resume'
109
);
1110

1211
ALTERTABLE crypto_keys
13-
ALTER COLUMN feature TYPEcrypto_key_feature_old
14-
USING (feature::text::crypto_key_feature_old);
12+
ALTER COLUMN feature TYPEold_crypto_key_feature
13+
USING (feature::text::old_crypto_key_feature);
1514

1615
DROPTYPE crypto_key_feature;
1716

18-
ALTERTYPEcrypto_key_feature_old RENAME TO crypto_key_feature;
17+
ALTERTYPEold_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+
CREATETYPEnew_crypto_key_featureAS ENUM (
3+
'workspace_apps_token',
4+
'workspace_apps_api_key',
5+
'oidc_convert',
6+
'tailnet_resume'
7+
);
8+
9+
DELETEFROM crypto_keysWHERE feature='workspace_apps';
10+
11+
-- Drop the old type and rename the new one
12+
ALTERTABLE crypto_keys
13+
ALTER COLUMN feature TYPE new_crypto_key_feature
14+
USING (feature::text::new_crypto_key_feature);
15+
16+
DROPTYPE crypto_key_feature;
17+
18+
ALTERTYPE 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)

[8]ページ先頭

©2009-2025 Movatter.jp