[open-ils-commits] r17916 - in branches/rel_2_0/Open-ILS/src/sql/Pg: . upgrade (scottmk)

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Sep 23 09:45:10 EDT 2010


Author: scottmk
Date: 2010-09-23 09:45:08 -0400 (Thu, 23 Sep 2010)
New Revision: 17916

Added:
   branches/rel_2_0/Open-ILS/src/sql/Pg/upgrade/0415.schema.rename-field-class-fkey.sql
Modified:
   branches/rel_2_0/Open-ILS/src/sql/Pg/002.schema.config.sql
Log:
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


Modified: branches/rel_2_0/Open-ILS/src/sql/Pg/002.schema.config.sql
===================================================================
--- branches/rel_2_0/Open-ILS/src/sql/Pg/002.schema.config.sql	2010-09-23 13:45:06 UTC (rev 17915)
+++ branches/rel_2_0/Open-ILS/src/sql/Pg/002.schema.config.sql	2010-09-23 13:45:08 UTC (rev 17916)
@@ -70,7 +70,7 @@
     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,

Added: branches/rel_2_0/Open-ILS/src/sql/Pg/upgrade/0415.schema.rename-field-class-fkey.sql
===================================================================
--- branches/rel_2_0/Open-ILS/src/sql/Pg/upgrade/0415.schema.rename-field-class-fkey.sql	                        (rev 0)
+++ branches/rel_2_0/Open-ILS/src/sql/Pg/upgrade/0415.schema.rename-field-class-fkey.sql	2010-09-23 13:45:08 UTC (rev 17916)
@@ -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;



More information about the open-ils-commits mailing list