LP1849212: (follow-up) Don't use group ids in upgrade scripts
authorJason Boyer <JBoyer@equinoxinitiative.org>
Tue, 29 Sep 2020 14:32:48 +0000 (10:32 -0400)
committerJason Boyer <JBoyer@equinoxinitiative.org>
Tue, 29 Sep 2020 14:32:48 +0000 (10:32 -0400)
Previously if there was not a permission group with an id of 9
this upgrade script would fail. Changing the consatruction to
match the seed data allows the insert to benignly do nothing if
the group is missing. Also, the permission is made grantable.

Signed-off-by: Jason Boyer <JBoyer@equinoxinitiative.org>
Open-ILS/src/sql/Pg/upgrade/1232.schema.course-materials-module.sql
Open-ILS/src/sql/Pg/version-upgrade/3.5.1-3.6-beta1-upgrade-db.sql

index 37d909d..d96797d 100644 (file)
@@ -71,7 +71,18 @@ INSERT INTO permission.perm_list(id, code, description)
         )
     );
 
-INSERT INTO permission.grp_perm_map(perm, grp, depth) VALUES (624, 9, 0), (624, 11, 0), (624, 12, 0), (624, 13, 0);
+INSERT INTO permission.grp_perm_map (grp, perm, depth, grantable)
+    SELECT
+        pgt.id, perm.id, aout.depth, TRUE
+    FROM
+        permission.grp_tree pgt,
+        permission.perm_list perm,
+        actor.org_unit_type aout
+    WHERE
+        pgt.name = 'Circulation Administrator' AND
+        aout.name = 'Consortium' AND
+        perm.code = 'MANAGE_RESERVES'
+;
 
 INSERT INTO config.org_unit_setting_type 
     (grp, name, datatype, label, description, fm_class)
index 9b6578a..7844ead 100644 (file)
@@ -1734,7 +1734,18 @@ INSERT INTO permission.perm_list(id, code, description)
         )
     );
 
-INSERT INTO permission.grp_perm_map(perm, grp, depth) VALUES (624, 9, 0);
+INSERT INTO permission.grp_perm_map (grp, perm, depth, grantable)
+    SELECT
+        pgt.id, perm.id, aout.depth, TRUE
+    FROM
+        permission.grp_tree pgt,
+        permission.perm_list perm,
+        actor.org_unit_type aout
+    WHERE
+        pgt.name = 'Circulation Administrator' AND
+        aout.name = 'Consortium' AND
+        perm.code = 'MANAGE_RESERVES'
+;
 
 INSERT INTO config.org_unit_setting_type 
     (grp, name, datatype, label, description, fm_class)