From: Remington Steed Date: Thu, 26 Feb 2015 21:21:48 +0000 (-0500) Subject: LP#1426133: Set merge_profile_id_seq explicitly X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=8d75bafea9614ede49b27d572c40cc04f3bb715f;p=evergreen%2Ftadl.git 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 --- 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 bf47472611..41bd54d020 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -12636,6 +12636,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;