Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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...
commit 8ba0cfd71ba68c0ad8e91f57af25eecd8468fb5c 1 parent 7c1a6d4
Sam Vilain samv authored

Showing 1 changed file with 10 additions and 10 deletions. Show diff stats Hide diff stats

  1. +10 10 constraints.sql
20 constraints.sql
@@ -33,13 +33,13 @@ alter table change_parents add constraint source_file_id_valid
33 33
34 34 -- checking all change number references are valid
35 35 alter table rev add constraint rev_change_valid
36   - foreign key (change) references change;
  36 + foreign key (change) references change deferrable;
37 37
38 38 alter table revcx add constraint revcx_change_valid
39   - foreign key (change) references change;
  39 + foreign key (change) references change deferrable;
40 40
41 41 alter table change_branches add constraint change_branches_change_valid
42   - foreign key (change) references change;
  42 + foreign key (change) references change deferrable;
43 43
44 44 -- p4users primary key
45 45 alter table p4user
@@ -54,27 +54,27 @@ select * from change_desc where not exists
54 54
55 55 -- checking all depotpaths + revnums are valid
56 56 alter table revcx add constraint revcx_depot_rev_valid
57   - foreign key (depotpath, revision) references rev;
  57 + foreign key (depotpath, revision) references rev deferrable;
58 58 alter table rev_marks add constraint rev_marks_depot_rev_valid
59   - foreign key (depotpath,revision) references rev;
  59 + foreign key (depotpath,revision) references rev deferrable;
60 60
61 61 -- set up safety constraints for later additions
62 62 alter table change_marks add constraint change_marks_branch_valid
63   - foreign key (branchpath,change) references change_branches;
  63 + foreign key (branchpath,change) references change_branches deferrable;
64 64
65 65 create unique index change_parents_unique on change_parents
66 66 (branchpath,change,parent_branchpath,parent_change,ref);
67 67 alter table change_parents add constraint change_branchpath_valid
68 68 foreign key (branchpath,change)
69   - references change_branches;
  69 + references change_branches deferrable;
70 70 alter table change_parents add constraint change_parents_valid
71 71 foreign key (parent_branchpath, parent_change)
72   - references change_branches(branchpath, change);
  72 + references change_branches(branchpath, change) deferrable;
73 73 create unique index change_parents_sanity
74 74 on change_parents(change, branchpath, parent_branchpath,
75 75 parent_change, manual);
76 76
77   --- create indexes
  77 +-- create indexes:
78 78 create index integed_change_idx on integed (change);
79 79 create index integed_subject_idx on integed (subject, subject_maxrev);
80 80 create index integed_object_idx on integed (object, object_maxrev);
@@ -99,7 +99,7 @@ group by
99 99
100 100 -- checking all change number references are valid
101 101 alter table change add constraint change_who_user_valid
102   - foreign key (who_user) references p4user;
  102 + foreign key (who_user) references p4user deferrable;
103 103
104 104 -- the 'integed' table is denormalised, with rows normally appearing
105 105 -- 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.