Skip to content
Browse files

Make all foreign key constraints deferrable

This will be required later, when the load routine will temporarily delete
referenced rows to insert new versions of them.
  • Loading branch information...
1 parent 7c1a6d4 commit 8ba0cfd71ba68c0ad8e91f57af25eecd8468fb5c @samv samv committed Jan 31, 2008
Showing with 10 additions and 10 deletions.
  1. +10 −10 constraints.sql
View
20 constraints.sql
@@ -33,13 +33,13 @@ alter table change_parents add constraint source_file_id_valid
-- checking all change number references are valid
alter table rev add constraint rev_change_valid
- foreign key (change) references change;
+ foreign key (change) references change deferrable;
alter table revcx add constraint revcx_change_valid
- foreign key (change) references change;
+ foreign key (change) references change deferrable;
alter table change_branches add constraint change_branches_change_valid
- foreign key (change) references change;
+ foreign key (change) references change deferrable;
-- p4users primary key
alter table p4user
@@ -54,27 +54,27 @@ select * from change_desc where not exists
-- checking all depotpaths + revnums are valid
alter table revcx add constraint revcx_depot_rev_valid
- foreign key (depotpath, revision) references rev;
+ foreign key (depotpath, revision) references rev deferrable;
alter table rev_marks add constraint rev_marks_depot_rev_valid
- foreign key (depotpath,revision) references rev;
+ foreign key (depotpath,revision) references rev deferrable;
-- set up safety constraints for later additions
alter table change_marks add constraint change_marks_branch_valid
- foreign key (branchpath,change) references change_branches;
+ foreign key (branchpath,change) references change_branches deferrable;
create unique index change_parents_unique on change_parents
(branchpath,change,parent_branchpath,parent_change,ref);
alter table change_parents add constraint change_branchpath_valid
foreign key (branchpath,change)
- references change_branches;
+ references change_branches deferrable;
alter table change_parents add constraint change_parents_valid
foreign key (parent_branchpath, parent_change)
- references change_branches(branchpath, change);
+ references change_branches(branchpath, change) deferrable;
create unique index change_parents_sanity
on change_parents(change, branchpath, parent_branchpath,
parent_change, manual);
--- create indexes
+-- create indexes:
create index integed_change_idx on integed (change);
create index integed_subject_idx on integed (subject, subject_maxrev);
create index integed_object_idx on integed (object, object_maxrev);
@@ -99,7 +99,7 @@ group by
-- checking all change number references are valid
alter table change add constraint change_who_user_valid
- foreign key (who_user) references p4user;
+ foreign key (who_user) references p4user deferrable;
-- the 'integed' table is denormalised, with rows normally appearing
-- in pairs. However, these rows were missing their partners:

0 comments on commit 8ba0cfd

Please sign in to comment.
Something went wrong with that request. Please try again.