Skip to content

Commit

Permalink
add cascade to object-fk
Browse files Browse the repository at this point in the history
  • Loading branch information
BuckarooBanzay committed Dec 27, 2023
1 parent be38c83 commit efb1973
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion mapobjectdb/postgres/migrations/02_uuid.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ alter table objects add constraint objects_uid_unique UNIQUE (uid);
alter table object_attributes add object_uid uuid;
update object_attributes set object_uid = (select uid from objects o where o.id = objectid);
alter table object_attributes alter column object_uid set not null;
alter table object_attributes add constraint object_attributes_object_uid_fk FOREIGN KEY (object_uid) REFERENCES objects(uid);
alter table object_attributes
add constraint object_attributes_object_uid_fk
FOREIGN KEY (object_uid)
REFERENCES objects(uid)
on delete cascade;
create index object_attributes_object_uid on object_attributes(object_uid);

-- drop old id's
Expand Down

0 comments on commit efb1973

Please sign in to comment.