[open-ils-commits] r17482 - in trunk/Open-ILS/src/sql/Pg: . upgrade (gmc)
svn at svn.open-ils.org
svn at svn.open-ils.org
Fri Sep 3 15:17:03 EDT 2010
Author: gmc
Date: 2010-09-03 15:16:59 -0400 (Fri, 03 Sep 2010)
New Revision: 17482
Added:
trunk/Open-ILS/src/sql/Pg/upgrade/0387.schema.perm_list_fkeys_restrict_delete.sql
Modified:
trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
trunk/Open-ILS/src/sql/Pg/006.schema.permissions.sql
trunk/Open-ILS/src/sql/Pg/800.fkeys.sql
Log:
restrict deletion of perm_lists in use
Per suggestion by Mike Rylander; prevents overzealous
administrator from removing necessary permisions that
are in use.
TODO: UI to make it clear when that happens
Signed-off-by: Galen Charlton <gmc at esilibrary.com>
Modified: trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2010-09-03 19:15:18 UTC (rev 17481)
+++ trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2010-09-03 19:16:59 UTC (rev 17482)
@@ -68,7 +68,7 @@
install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
);
-INSERT INTO config.upgrade_log (version) VALUES ('0386'); -- berick
+INSERT INTO config.upgrade_log (version) VALUES ('0387'); -- gmc
CREATE TABLE config.bib_source (
id SERIAL PRIMARY KEY,
Modified: trunk/Open-ILS/src/sql/Pg/006.schema.permissions.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/006.schema.permissions.sql 2010-09-03 19:15:18 UTC (rev 17481)
+++ trunk/Open-ILS/src/sql/Pg/006.schema.permissions.sql 2010-09-03 19:16:59 UTC (rev 17482)
@@ -51,7 +51,7 @@
CREATE TABLE permission.grp_perm_map (
id SERIAL PRIMARY KEY,
grp INT NOT NULL REFERENCES permission.grp_tree (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
- perm INT NOT NULL REFERENCES permission.perm_list (id) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
+ perm INT NOT NULL REFERENCES permission.perm_list (id) ON UPDATE CASCADE ON DELETE RESTRICT DEFERRABLE INITIALLY DEFERRED,
depth INT NOT NULL,
grantable BOOL NOT NULL DEFAULT FALSE,
CONSTRAINT perm_grp_once UNIQUE (grp,perm)
@@ -60,7 +60,7 @@
CREATE TABLE permission.usr_perm_map (
id SERIAL PRIMARY KEY,
usr INT NOT NULL REFERENCES actor.usr (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
- perm INT NOT NULL REFERENCES permission.perm_list (id) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
+ perm INT NOT NULL REFERENCES permission.perm_list (id) ON UPDATE CASCADE ON DELETE RESTRICT DEFERRABLE INITIALLY DEFERRED,
depth INT NOT NULL,
grantable BOOL NOT NULL DEFAULT FALSE,
CONSTRAINT perm_usr_once UNIQUE (usr,perm)
@@ -69,7 +69,7 @@
CREATE TABLE permission.usr_object_perm_map (
id SERIAL PRIMARY KEY,
usr INT NOT NULL REFERENCES actor.usr (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
- perm INT NOT NULL REFERENCES permission.perm_list (id) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
+ perm INT NOT NULL REFERENCES permission.perm_list (id) ON UPDATE CASCADE ON DELETE RESTRICT DEFERRABLE INITIALLY DEFERRED,
object_type TEXT NOT NULL,
object_id TEXT NOT NULL,
grantable BOOL NOT NULL DEFAULT FALSE,
Modified: trunk/Open-ILS/src/sql/Pg/800.fkeys.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/800.fkeys.sql 2010-09-03 19:15:18 UTC (rev 17481)
+++ trunk/Open-ILS/src/sql/Pg/800.fkeys.sql 2010-09-03 19:16:59 UTC (rev 17482)
@@ -114,7 +114,7 @@
ALTER TABLE config.remote_account ADD CONSTRAINT config_remote_account_owner_fkey FOREIGN KEY (owner) REFERENCES actor.org_unit (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
-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 view_perm_fkey FOREIGN KEY (view_perm) REFERENCES permission.perm_list (id) ON UPDATE CASCADE ON DELETE RESTRICT 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;
COMMIT;
Added: 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 (rev 0)
+++ trunk/Open-ILS/src/sql/Pg/upgrade/0387.schema.perm_list_fkeys_restrict_delete.sql 2010-09-03 19:16:59 UTC (rev 17482)
@@ -0,0 +1,18 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0387'); --gmc
+
+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;
+
+COMMIT;
More information about the open-ils-commits
mailing list