]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/sql/Pg/upgrade/0415.schema.rename-field-class-fkey.sql
LP1894131 Sticky catalog holdings org select
[Evergreen.git] / Open-ILS / src / sql / Pg / upgrade / 0415.schema.rename-field-class-fkey.sql
1 -- Dropping and recreating a foreign key constraint for config.metabib_field,
2 -- in order to change its name.  WHen this foreign key was first introduced,
3 -- the upgrade script gave it one name and the base install script gave it
4 -- a different name.  Here we bring the names into sync.
5
6 BEGIN;
7
8 INSERT INTO config.upgrade_log (version) VALUES ('0415'); -- Scott McKellar
9
10 \qecho Dropping and recreating a foreign key in order to change its name.
11 \qecho If the DROP fails because the constraint doesn't exist under the old
12 \qecho name, or the ADD fails because it already exists under the new name,
13 \qecho then ignore the failure.
14
15 ALTER TABLE config.metabib_field
16         DROP CONSTRAINT field_class_fkey;
17
18 ALTER TABLE config.metabib_field
19         ADD CONSTRAINT metabib_field_field_class_fkey
20         FOREIGN KEY (field_class) REFERENCES config.metabib_class(name);
21
22 COMMIT;