From d01ba8ed9d4ec7078036f2ce767ff4ac4597ce8e Mon Sep 17 00:00:00 2001 From: Remington Steed Date: Thu, 26 Feb 2015 16:21:48 -0500 Subject: [PATCH] LP#1426133: Set merge_profile_id_seq explicitly Many database tables need to explicitly set the id sequence (often to 100) to provide room for stock data with static ids. This commit does so for vandelay.merge_profile, and also updates the ids of any non-stock profiles (both in the merge_profile table and in related settings). Signed-off-by: Remington Steed Signed-off-by: Ben Shum --- Open-ILS/src/sql/Pg/950.data.seed-values.sql | 2 ++ ...a.redo_vandelay_merge_profile_sequence.sql | 24 +++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 Open-ILS/src/sql/Pg/upgrade/XXXX.schema.redo_vandelay_merge_profile_sequence.sql diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql index 5abcaaf04d..fa7fcc3a06 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -12646,6 +12646,8 @@ INSERT INTO vandelay.merge_profile (id, owner, name, replace_spec) INSERT INTO vandelay.merge_profile (id, owner, name, preserve_spec) VALUES (2, 1, oils_i18n_gettext(2, 'Full Overlay', 'vmp', 'name'), '901c'); +SELECT SETVAL('vandelay.merge_profile'::TEXT, 100); + -- user activity seed data -- INSERT INTO config.usr_activity_type (id, ewho, ewhat, ehow, egroup, label) VALUES diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.redo_vandelay_merge_profile_sequence.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.redo_vandelay_merge_profile_sequence.sql new file mode 100644 index 0000000000..bf0f5c99f6 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.redo_vandelay_merge_profile_sequence.sql @@ -0,0 +1,24 @@ +BEGIN; + +--SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version); + +--stock evergreen comes with 2 merge profiles; move any custom profiles +UPDATE vandelay.merge_profile SET id = id + 100 WHERE id > 2; + +--update the same ids in org unit settings, stored in double quotes +UPDATE actor.org_unit_setting + SET value = '"' || merge_profile_id+100 || '"' + FROM ( + SELECT id, (regexp_matches(value, '"(\d+)"'))[1]::int as merge_profile_id FROM actor.org_unit_setting + WHERE name IN ( + 'acq.upload.default.vandelay.low_quality_fall_thru_profile', + 'acq.upload.default.vandelay.merge_profile' + ) + ) as foo + WHERE actor.org_unit_setting.id = foo.id + AND foo.merge_profile_id > 2; + +--set sequence's next value to 100, or more if necessary +SELECT SETVAL('vandelay.merge_profile_id_seq', GREATEST(100, (SELECT MAX(id) FROM vandelay.merge_profile))); + +COMMIT; -- 2.43.2