[open-ils-commits] r17632 - trunk/Open-ILS/src/sql/Pg/upgrade (atz)
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon Sep 13 12:34:35 EDT 2010
Author: atz
Date: 2010-09-13 12:34:32 -0400 (Mon, 13 Sep 2010)
New Revision: 17632
Modified:
trunk/Open-ILS/src/sql/Pg/upgrade/0385.schema.perm_list_fkeys.sql
trunk/Open-ILS/src/sql/Pg/upgrade/0387.schema.perm_list_fkeys_restrict_delete.sql
Log:
Prevent failure of update scripts.
Modified: trunk/Open-ILS/src/sql/Pg/upgrade/0385.schema.perm_list_fkeys.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/upgrade/0385.schema.perm_list_fkeys.sql 2010-09-13 15:55:21 UTC (rev 17631)
+++ trunk/Open-ILS/src/sql/Pg/upgrade/0385.schema.perm_list_fkeys.sql 2010-09-13 16:34:32 UTC (rev 17632)
@@ -1,3 +1,16 @@
+
+-- First drop the stuff we are going to (re)create. If it fails for not existing, fine.
+-- Some constraints might have different names, so we try all of them.
+ALTER TABLE permission.grp_perm_map DROP CONSTRAINT grp_perm_map_perm_fkey;
+ALTER TABLE permission.usr_perm_map DROP CONSTRAINT usr_perm_map_perm_fkey;
+ALTER TABLE permission.usr_object_perm_map DROP CONSTRAINT usr_object_perm_map_perm_fkey;
+
+ALTER TABLE config.org_unit_setting_type DROP CONSTRAINT view_perm_fkey;
+ALTER TABLE config.org_unit_setting_type DROP CONSTRAINT update_perm_fkey;
+ALTER TABLE config.org_unit_setting_type DROP CONSTRAINT org_unit_setting_type_view_perm_fkey; -- alternate name
+ALTER TABLE config.org_unit_setting_type DROP CONSTRAINT org_unit_setting_type_update_perm_fkey; -- alternate name
+
+
BEGIN;
INSERT INTO config.upgrade_log (version) VALUES ('0385'); --gmc
@@ -2,15 +15,10 @@
-ALTER TABLE permission.grp_perm_map DROP CONSTRAINT grp_perm_map_perm_fkey;
ALTER TABLE permission.grp_perm_map ADD CONSTRAINT grp_perm_map_perm_fkey FOREIGN KEY (perm)
REFERENCES permission.perm_list (id) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
-ALTER TABLE permission.usr_perm_map DROP CONSTRAINT usr_perm_map_perm_fkey;
ALTER TABLE permission.usr_perm_map ADD CONSTRAINT usr_perm_map_perm_fkey FOREIGN KEY (perm)
REFERENCES permission.perm_list (id) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
-ALTER TABLE permission.usr_object_perm_map DROP CONSTRAINT usr_object_perm_map_perm_fkey;
ALTER TABLE permission.usr_object_perm_map ADD CONSTRAINT usr_object_perm_map_perm_fkey FOREIGN KEY (perm)
REFERENCES permission.perm_list (id) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
-ALTER TABLE config.org_unit_setting_type DROP CONSTRAINT view_perm_fkey;
-ALTER TABLE config.org_unit_setting_type ADD CONSTRAINT view_perm_fkey FOREIGN KEY (view_perm) REFERENCES permission.perm_list (id) ON UPDATE CASCADE ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
-ALTER TABLE config.org_unit_setting_type DROP CONSTRAINT update_perm_fkey;
+ALTER TABLE config.org_unit_setting_type ADD CONSTRAINT view_perm_fkey FOREIGN KEY (view_perm ) REFERENCES permission.perm_list (id) ON UPDATE CASCADE ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE config.org_unit_setting_type ADD CONSTRAINT update_perm_fkey FOREIGN KEY (update_perm) REFERENCES permission.perm_list (id) ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED;
Modified: trunk/Open-ILS/src/sql/Pg/upgrade/0387.schema.perm_list_fkeys_restrict_delete.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/upgrade/0387.schema.perm_list_fkeys_restrict_delete.sql 2010-09-13 15:55:21 UTC (rev 17631)
+++ trunk/Open-ILS/src/sql/Pg/upgrade/0387.schema.perm_list_fkeys_restrict_delete.sql 2010-09-13 16:34:32 UTC (rev 17632)
@@ -1,3 +1,11 @@
+
+-- First drop the stuff we are going to (re)create. If it fails for not existing, fine.
+
+ALTER TABLE permission.grp_perm_map DROP CONSTRAINT grp_perm_map_perm_fkey;
+ALTER TABLE permission.usr_perm_map DROP CONSTRAINT usr_perm_map_perm_fkey;
+ALTER TABLE permission.usr_object_perm_map DROP CONSTRAINT usr_object_perm_map_perm_fkey;
+ALTER TABLE config.org_unit_setting_type DROP CONSTRAINT view_perm_fkey;
+
BEGIN;
INSERT INTO config.upgrade_log (version) VALUES ('0387'); --gmc
@@ -2,13 +10,9 @@
-ALTER TABLE permission.grp_perm_map DROP CONSTRAINT grp_perm_map_perm_fkey;
ALTER TABLE permission.grp_perm_map ADD CONSTRAINT grp_perm_map_perm_fkey FOREIGN KEY (perm)
REFERENCES permission.perm_list (id) ON UPDATE CASCADE ON DELETE RESTRICT DEFERRABLE INITIALLY DEFERRED;
-ALTER TABLE permission.usr_perm_map DROP CONSTRAINT usr_perm_map_perm_fkey;
ALTER TABLE permission.usr_perm_map ADD CONSTRAINT usr_perm_map_perm_fkey FOREIGN KEY (perm)
REFERENCES permission.perm_list (id) ON UPDATE CASCADE ON DELETE RESTRICT DEFERRABLE INITIALLY DEFERRED;
-ALTER TABLE permission.usr_object_perm_map DROP CONSTRAINT usr_object_perm_map_perm_fkey;
ALTER TABLE permission.usr_object_perm_map ADD CONSTRAINT usr_object_perm_map_perm_fkey FOREIGN KEY (perm)
REFERENCES permission.perm_list (id) ON UPDATE CASCADE ON DELETE RESTRICT DEFERRABLE INITIALLY DEFERRED;
-ALTER TABLE config.org_unit_setting_type DROP CONSTRAINT view_perm_fkey;
ALTER TABLE config.org_unit_setting_type ADD CONSTRAINT view_perm_fkey FOREIGN KEY (view_perm) REFERENCES permission.perm_list (id) ON UPDATE CASCADE ON DELETE RESTRICT DEFERRABLE INITIALLY DEFERRED;
More information about the open-ils-commits
mailing list