Complete shared contour project linking and scoped application onboarding
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"schemaVersion": "nodedc.device-b2-shared-contours.v1",
|
||||
"releaseId": "device-b2-shared-contours-v1-20261001-001",
|
||||
"baselineReleaseId": "device-core-release-v1-r37-1b3001dfa12598af28882232336d837514502718",
|
||||
"baselineSha256": "fca735b4177ba5397e2af31520682aeb17670a8d38a19176be2c08f07f37dffe",
|
||||
"files": {
|
||||
"deployment/device-b2-shared-contours-v1.sql": "caff93f717bbd61ebaf8ffec0b9b2ad04885da22c4e332c1a4586e149faab57a",
|
||||
"deployment/device-b2-shared-contours-v1.rollback.sql": "f862da8316695d162167bd1fa854edcbf10d82f57462e3021cf199e72ef16b4f"
|
||||
},
|
||||
"transition": "one-contour-many-projects",
|
||||
"services": [],
|
||||
"rollback": "refuse-multiple-projects;preserve-all-rows"
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
begin;
|
||||
set local lock_timeout = '5s';
|
||||
set local statement_timeout = '30s';
|
||||
lock table device_b2_contour_links in access exclusive mode;
|
||||
do $$
|
||||
begin
|
||||
if obj_description('device_b2_contour_links'::regclass) is distinct from 'nodedc.device-b2-shared-contours/v1'
|
||||
or (select pg_get_constraintdef(oid) from pg_constraint
|
||||
where conrelid='device_b2_contour_links'::regclass and contype='p')
|
||||
is distinct from 'PRIMARY KEY (source_id, contour_id, project_id)' then
|
||||
raise exception 'device_b2_shared_contours_rollback_predecessor_mismatch';
|
||||
end if;
|
||||
if exists(select 1 from device_b2_contour_links group by source_id,contour_id having count(*)>1) then
|
||||
raise exception 'device_b2_shared_contours_rollback_would_lose_links';
|
||||
end if;
|
||||
end $$;
|
||||
alter table device_b2_contour_links drop constraint device_b2_contour_links_pkey;
|
||||
alter table device_b2_contour_links add primary key (source_id, contour_id);
|
||||
comment on table device_b2_contour_links is 'nodedc.device-b2-foundation/v1';
|
||||
commit;
|
||||
@@ -0,0 +1,32 @@
|
||||
begin;
|
||||
set local lock_timeout = '5s';
|
||||
set local statement_timeout = '30s';
|
||||
|
||||
-- Separate, versioned foundation transition. Never run from application startup.
|
||||
-- Preserve every assignment; only the identity of an assignment becomes a triple.
|
||||
lock table device_b2_contour_links in access exclusive mode;
|
||||
create temporary table device_b2_links_before on commit drop as
|
||||
select * from device_b2_contour_links;
|
||||
do $$
|
||||
begin
|
||||
if obj_description('device_b2_contour_links'::regclass) is distinct from 'nodedc.device-b2-foundation/v1'
|
||||
or (select pg_get_constraintdef(oid) from pg_constraint
|
||||
where conrelid='device_b2_contour_links'::regclass and contype='p')
|
||||
is distinct from 'PRIMARY KEY (source_id, contour_id)' then
|
||||
raise exception 'device_b2_shared_contours_predecessor_mismatch';
|
||||
end if;
|
||||
end $$;
|
||||
alter table device_b2_contour_links drop constraint device_b2_contour_links_pkey;
|
||||
alter table device_b2_contour_links add primary key (source_id, contour_id, project_id);
|
||||
comment on table device_b2_contour_links is 'nodedc.device-b2-shared-contours/v1';
|
||||
do $$
|
||||
begin
|
||||
if exists(
|
||||
(select * from device_b2_links_before except all select * from device_b2_contour_links)
|
||||
union all
|
||||
(select * from device_b2_contour_links except all select * from device_b2_links_before)
|
||||
) then
|
||||
raise exception 'device_b2_shared_contours_row_preservation_failed';
|
||||
end if;
|
||||
end $$;
|
||||
commit;
|
||||
Reference in New Issue
Block a user