You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit d2f0893
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: packages/db/maintenance/project-membership.sql
+12-3Lines changed: 12 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -5,9 +5,16 @@ SET statement_timeout = '60s';
5
5
--> statement-breakpoint
6
6
DO $$ BEGIN
7
7
IF to_regclass('public.project_membership_rollout') IS NULL THEN
8
-
RAISE EXCEPTION 'Project membership rollout marker is missing' USING ERRCODE ='55000';
9
-
END IF;
10
-
IF NOT EXISTS (SELECT1FROMpublic.project_membership_rolloutWHERE id ='membership'AND phase ='column') THEN
8
+
IF to_regclass('public.project_workspace') IS NOT NULL
9
+
OR NOT EXISTS (SELECT1FROM pg_attribute WHERE attrelid ='public.workspace'::regclass
10
+
AND attname ='project_id'AND attnotnull AND NOT attisdropped)
11
+
OR (SELECTcount(*) FROM pg_constraint
12
+
WHERE conrelid ='public.workspace'::regclass AND contype ='f'AND convalidated
13
+
AND conname IN ('workspace_project_id_project_id_fk',
14
+
'workspace_project_organization_fk', 'workspace_fork_project_fk')) <>3 THEN
15
+
RAISE EXCEPTION 'Project membership rollout marker is missing before completed contraction' USING ERRCODE ='55000';
16
+
END IF;
17
+
ELSIF NOT EXISTS (SELECT1FROMpublic.project_membership_rolloutWHERE id ='membership'AND phase ='column') THEN
11
18
RAISE EXCEPTION 'Project membership authority must switch before enforcement' USING ERRCODE ='55000';
12
19
END IF;
13
20
IF NOT pg_try_advisory_lock(hashtextextended('sim:project-backfill-operator', 0)) THEN
@@ -189,6 +196,8 @@ ALTER TABLE workspace DROP CONSTRAINT IF EXISTS workspace_project_id_present;
189
196
--> statement-breakpoint
190
197
-- migration-safe: contract of #8830, gated on its authority-aware release being fully deployed, incompatible app/worker versions having drained, and the column-authority switch being committed; no supported application reader or writer then needs this connector.
191
198
DROPTABLE IF EXISTS project_workspace;
199
+
-- migration-safe: contract of #8830, whose deployed readers recognize the required column and validated foreign keys after both temporary tables disappear atomically under the workspace barrier.
organizationScopeKey: text('organization_scope_key').generatedAlwaysAs(sql\`CASE WHEN organization_id IS NULL THEN 'personal' ELSE 'organization:' || organization_id END\`),
0 commit comments