basyx commited on
Commit
6ca12fe
·
verified ·
1 Parent(s): 77fb0a2

fix: repair missing project brand kit column

Browse files
app/projects/migrations/0015_repair_project_brand_kit_column.sql ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ -- Repair projects.brand_kit_id when the brand-kit migration was only partially applied.
2
+ -- Safe to re-run; preserves existing project rows and is intentionally forward-only.
3
+ begin;
4
+
5
+ alter table projects
6
+ add column if not exists brand_kit_id text;
7
+
8
+ do $$
9
+ begin
10
+ if not exists (
11
+ select 1
12
+ from pg_constraint
13
+ where conname = 'fk_projects_brand_kit'
14
+ and conrelid = 'projects'::regclass
15
+ ) then
16
+ alter table projects
17
+ add constraint fk_projects_brand_kit
18
+ foreign key (brand_kit_id)
19
+ references brand_kits(id)
20
+ on delete restrict;
21
+ end if;
22
+ end
23
+ $$;
24
+
25
+ create index if not exists ix_projects_workspace_brand_kit
26
+ on projects(workspace_id, brand_kit_id);
27
+
28
+ commit;