Wrap upgrade script for CREATE_REPORT_TEMPLATE permission
authorDan Scott <dscott@laurentian.ca>
Mon, 19 Dec 2011 16:17:12 +0000 (11:17 -0500)
committerDan Scott <dscott@laurentian.ca>
Mon, 19 Dec 2011 16:18:18 +0000 (11:18 -0500)
Permissions to create report templates will automatically be added to
any group that currently has the ability to run reports as part of the
upgrade process; if you want to make use of the ability to prevent some
groups from creating ad-hoc reports, remove the CREATE_REPORT_TEMPLATE
permission from permission.grp_perm_map for that group.

Signed-off-by: Dan Scott <dscott@laurentian.ca>
Open-ILS/src/sql/Pg/002.schema.config.sql
Open-ILS/src/sql/Pg/upgrade/0659.add_create_report_perms.sql [new file with mode: 0644]
Open-ILS/src/sql/Pg/upgrade/XXXX.report_perms.sql [deleted file]

index 1573edb..defe858 100644 (file)
@@ -86,7 +86,7 @@ CREATE TRIGGER no_overlapping_deps
     BEFORE INSERT OR UPDATE ON config.db_patch_dependencies
     FOR EACH ROW EXECUTE PROCEDURE evergreen.array_overlap_check ('deprecates');
 
-INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0658', :eg_version); -- jamesrf/dbs
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0659', :eg_version); -- tsbere/dbs
 
 CREATE TABLE config.bib_source (
        id              SERIAL  PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/0659.add_create_report_perms.sql b/Open-ILS/src/sql/Pg/upgrade/0659.add_create_report_perms.sql
new file mode 100644 (file)
index 0000000..0133ff8
--- /dev/null
@@ -0,0 +1,25 @@
+-- Evergreen DB patch 0659.add_create_report_perms.sql
+--
+-- Add a permission to control the ability to create report templates
+--
+BEGIN;
+
+-- check whether patch can be applied
+SELECT evergreen.upgrade_deps_block_check('0659', :eg_version);
+
+-- FIXME: add/check SQL statements to perform the upgrade
+INSERT INTO permission.perm_list ( id, code, description ) VALUES
+ ( 516, 'CREATE_REPORT_TEMPLATE', oils_i18n_gettext( 516,
+    'Allows a user to create report templates', 'ppl', 'description' ));
+
+INSERT INTO permission.grp_perm_map (grp, perm, depth, grantable)
+    SELECT grp, 516, depth, grantable
+        FROM permission.grp_perm_map
+        WHERE perm = (
+            SELECT id
+                FROM permission.perm_list
+                WHERE code = 'RUN_REPORTS'
+        );
+
+
+COMMIT;
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.report_perms.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.report_perms.sql
deleted file mode 100644 (file)
index 1eb1ff3..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-INSERT INTO permission.perm_list ( id, code, description ) VALUES
- ( 516, 'CREATE_REPORT_TEMPLATE', oils_i18n_gettext( 516,
-    'Allows a user to create report templates', 'ppl', 'description' ));
-
-INSERT INTO permission.grp_perm_map (grp, perm, depth, grantable)
-    SELECT grp, 516, depth, grantable
-        FROM permission.grp_perm_map
-        WHERE perm = (
-            SELECT id
-                FROM permission.perm_list
-                WHERE code = 'RUN_REPORTS'
-        );