Need to renumber from highest to lowest. Because the primary
key constraint is not deferred, doing the renumbering in a single
statement will fail if there is overlap between the set of
existing pgt.id values and the set of {pgt.id + 100}.
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Bill Erickson <berick@esilibrary.com>
-- Prevent conflicts with existing custom permission groups; as of 2.0.10,
-- highest permission.grp_tree ID was 10 for Local System Administrator
-UPDATE permission.grp_tree SET id = id + 100 WHERE id > 10;
+DO $$
+DECLARE i INTEGER;
+BEGIN
+ FOR i IN
+ SELECT id FROM permission.grp_tree WHERE id > 10 ORDER BY id DESC
+ LOOP
+ UPDATE permission.grp_tree SET id = id + 100 WHERE id = i;
+ END LOOP;
+END;
+$$;
UPDATE permission.grp_tree SET parent = parent + 100 WHERE parent > 10;
UPDATE actor.usr SET profile = profile + 100 WHERE profile > 10;
UPDATE permission.grp_perm_map SET grp = grp + 100 WHERE grp > 10;