LP1842940: stamping and slight tweak to upgrade script
authorJane Sandberg <sandbej@linnbenton.edu>
Tue, 1 Oct 2019 21:47:07 +0000 (14:47 -0700)
committerJane Sandberg <sandbej@linnbenton.edu>
Tue, 1 Oct 2019 22:52:05 +0000 (15:52 -0700)
Mike Rylander suggested the INSERT ... SELECT ... WHERE NOT
EXISTS approach, since this fix is being backported to older
releases, and we don't want to cause duplicate entries or
upgrade failures if the perm already exists

Signed-off-by: Jane Sandberg <sandbej@linnbenton.edu>
Open-ILS/src/sql/Pg/002.schema.config.sql
Open-ILS/src/sql/Pg/upgrade/1191.data.lp1842940_staff_edit_self_perm.sql [new file with mode: 0644]
Open-ILS/src/sql/Pg/upgrade/XXXX.data.lp1842940_staff_edit_self_perm.sql [deleted file]

index 17b7556..d40a36d 100644 (file)
@@ -92,7 +92,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 ('1190', :eg_version); -- Dyrcona/gmcharlt
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('1191', :eg_version); -- miker/jeffdavis/sandbergja
 
 CREATE TABLE config.bib_source (
        id              SERIAL  PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/1191.data.lp1842940_staff_edit_self_perm.sql b/Open-ILS/src/sql/Pg/upgrade/1191.data.lp1842940_staff_edit_self_perm.sql
new file mode 100644 (file)
index 0000000..7c88580
--- /dev/null
@@ -0,0 +1,14 @@
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('1191', :eg_version);
+
+INSERT INTO permission.perm_list ( id, code, description ) SELECT DISTINCT
+  619,
+  'EDIT_SELF_IN_CLIENT',
+  oils_i18n_gettext(619,
+    'Allow a user to edit their own account in the staff client', 'ppl', 'description'
+  )
+  FROM permission.perm_list
+  WHERE NOT EXISTS (SELECT 1 FROM permission.perm_list WHERE code = 'EDIT_SELF_IN_CLIENT');
+
+COMMIT;
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.lp1842940_staff_edit_self_perm.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.lp1842940_staff_edit_self_perm.sql
deleted file mode 100644 (file)
index 2a12998..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-BEGIN;
-
-SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
-
-INSERT INTO permission.perm_list ( id, code, description ) VALUES
-( 619, 'EDIT_SELF_IN_CLIENT', oils_i18n_gettext(619,
-    'Allow a user to edit their own account in the staff client', 'ppl', 'description'))
-;
-
-COMMIT;