From a0224d6dc5ed80ab0a2b1352bff21b8a590074ec Mon Sep 17 00:00:00 2001 From: scottmk Date: Thu, 23 Sep 2010 13:45:06 +0000 Subject: [PATCH] Dropping and recreating a foreign key constraint for config.metabib_field, in order to change its name. WHen this foreign key was first introduced, the upgrade script gave it one name and the base install script gave it a different name. Here we bring the names into sync. M Open-ILS/src/sql/Pg/002.schema.config.sql A Open-ILS/src/sql/Pg/upgrade/0415.schema.rename-field-class-fkey.sql git-svn-id: svn://svn.open-ils.org/ILS/trunk@17915 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/sql/Pg/002.schema.config.sql | 2 +- .../0415.schema.rename-field-class-fkey.sql | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/0415.schema.rename-field-class-fkey.sql diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index 10784c3c2..3baba2fcd 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -70,7 +70,7 @@ CREATE TABLE config.upgrade_log ( install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW() ); -INSERT INTO config.upgrade_log (version) VALUES ('0414'); -- Scott McKellar +INSERT INTO config.upgrade_log (version) VALUES ('0415'); -- Scott McKellar CREATE TABLE config.bib_source ( id SERIAL PRIMARY KEY, diff --git a/Open-ILS/src/sql/Pg/upgrade/0415.schema.rename-field-class-fkey.sql b/Open-ILS/src/sql/Pg/upgrade/0415.schema.rename-field-class-fkey.sql new file mode 100644 index 000000000..81ceaaf41 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/0415.schema.rename-field-class-fkey.sql @@ -0,0 +1,22 @@ +-- Dropping and recreating a foreign key constraint for config.metabib_field, +-- in order to change its name. WHen this foreign key was first introduced, +-- the upgrade script gave it one name and the base install script gave it +-- a different name. Here we bring the names into sync. + +BEGIN; + +INSERT INTO config.upgrade_log (version) VALUES ('0415'); -- Scott McKellar + +\qecho Dropping and recreating a foreign key in order to change its name. +\qecho If the DROP fails because the constraint doesn't exist under the old +\qecho name, or the ADD fails because it already exists under the new name, +\qecho then ignore the failure. + +ALTER TABLE config.metabib_field + DROP CONSTRAINT field_class_fkey; + +ALTER TABLE config.metabib_field + ADD CONSTRAINT metabib_field_field_class_fkey + FOREIGN KEY (field_class) REFERENCES config.metabib_class(name); + +COMMIT; -- 2.11.0