diff options
Diffstat (limited to 'util/updates/update_1.22.sql')
-rw-r--r-- | util/updates/update_1.22.sql | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/util/updates/update_1.22.sql b/util/updates/update_1.22.sql index cc475b32..96228955 100644 --- a/util/updates/update_1.22.sql +++ b/util/updates/update_1.22.sql @@ -12,3 +12,13 @@ ALTER TABLE vn ALTER COLUMN rgraph DROP NOT NULL; ALTER TABLE vn ALTER COLUMN rgraph SET DEFAULT NULL; UPDATE vn SET rgraph = NULL WHERE rgraph = 0; + +-- add foreign table constraint to changes.causedby +ALTER TABLE changes ALTER COLUMN causedby DROP NOT NULL; +ALTER TABLE changes ALTER COLUMN causedby SET DEFAULT NULL; +UPDATE changes c SET causedby = NULL + WHERE causedby = 0 + -- yup, there are some problems caused by deleted revisions in older versions of the site + OR NOT EXISTS(SELECT 1 FROM changes WHERE c.causedby = id); +ALTER TABLE changes ADD FOREIGN KEY (causedby) REFERENCES changes (id) DEFERRABLE INITIALLY DEFERRED; + |