From: Kathy Lussier Date: Wed, 19 Apr 2017 17:00:10 +0000 (-0400) Subject: LP#1680554: Stamping upgrade script for fix browse definition ids X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=499f9a073d9e305b206f54bc3d3f442976081e09;p=Evergreen.git LP#1680554: Stamping upgrade script for fix browse definition ids Signed-off-by: Kathy Lussier --- diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index 8b2d9c312e..bfeeb14776 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -91,7 +91,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 ('1032', :eg_version); -- Bmagic/csharp/gmcharlt +INSERT INTO config.upgrade_log (version, applied_to) VALUES ('1033', :eg_version); -- gmcharlt/kmlussier CREATE TABLE config.bib_source ( id SERIAL PRIMARY KEY, diff --git a/Open-ILS/src/sql/Pg/upgrade/1033.data.fix_subject_browse_mappings.sql b/Open-ILS/src/sql/Pg/upgrade/1033.data.fix_subject_browse_mappings.sql new file mode 100644 index 0000000000..19226bbba1 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/1033.data.fix_subject_browse_mappings.sql @@ -0,0 +1,75 @@ +BEGIN; + +SELECT evergreen.upgrade_deps_block_check('1033', :eg_version); + +-- correctly turn off browsing for subjectd|geograhic and +-- subject|temporal now that the *_browse versions exist. This is +-- a no-op in a database that was started at version 2.12.0. +UPDATE config.metabib_field +SET browse_field = FALSE +WHERE field_class = 'subject' AND name = 'geographic' +AND browse_field +AND id = 11; +UPDATE config.metabib_field +SET browse_field = FALSE +WHERE field_class = 'subject' AND name = 'temporal' +AND browse_field +AND id = 13; + +select b.tag, idx.name +from authority.control_set_bib_field b +join authority.control_set_bib_field_metabib_field_map map on (b.id = map.bib_field) +join config.metabib_field idx on (map.metabib_field = idx.id) +order by b.tag; + +-- and fix bib field mapping if necessasry +UPDATE authority.control_set_bib_field_metabib_field_map map +SET metabib_field = cmf.id +FROM config.metabib_field cmf +WHERE cmf.field_class = 'subject' AND cmf.name= 'temporal_browse' +AND map.bib_field IN ( + SELECT b.id + FROM authority.control_set_bib_field b + JOIN authority.control_set_authority_field a + ON (b.authority_field = a.id) + AND a.tag = '148' +) +AND map.metabib_field IN ( + SELECT id + FROM config.metabib_field + WHERE field_class = 'subject' AND name = 'geographic_browse' +); +UPDATE authority.control_set_bib_field_metabib_field_map map +SET metabib_field = cmf.id +FROM config.metabib_field cmf +WHERE cmf.field_class = 'subject' AND cmf.name= 'geographic_browse' +AND map.bib_field IN ( + SELECT b.id + FROM authority.control_set_bib_field b + JOIN authority.control_set_authority_field a + ON (b.authority_field = a.id) + AND a.tag = '151' +) +AND map.metabib_field IN ( + SELECT id + FROM config.metabib_field + WHERE field_class = 'subject' AND name = 'temporal_browse' +); + +\qecho Verify that bib subject fields appear to be mapped to +\qecho to correct browse indexes +SELECT b.id, b.tag, idx.field_class, idx.name +FROM authority.control_set_bib_field b +JOIN authority.control_set_bib_field_metabib_field_map map ON (b.id = map.bib_field) +JOIN config.metabib_field idx ON (map.metabib_field = idx.id) +WHERE tag ~ '^6' +ORDER BY b.tag; + +COMMIT; + +\qecho This is a browse-only reingest of your bib records. It may take a while. +\qecho You may cancel now without losing the effect of the rest of the +\qecho upgrade script, and arrange the reingest later. +\qecho . +SELECT metabib.reingest_metabib_field_entries(id, TRUE, FALSE, TRUE) + FROM biblio.record_entry; diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.fix_subject_browse_mappings.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.fix_subject_browse_mappings.sql deleted file mode 100644 index d4f696e727..0000000000 --- a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.fix_subject_browse_mappings.sql +++ /dev/null @@ -1,75 +0,0 @@ -BEGIN; - -SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version); - --- correctly turn off browsing for subjectd|geograhic and --- subject|temporal now that the *_browse versions exist. This is --- a no-op in a database that was started at version 2.12.0. -UPDATE config.metabib_field -SET browse_field = FALSE -WHERE field_class = 'subject' AND name = 'geographic' -AND browse_field -AND id = 11; -UPDATE config.metabib_field -SET browse_field = FALSE -WHERE field_class = 'subject' AND name = 'temporal' -AND browse_field -AND id = 13; - -select b.tag, idx.name -from authority.control_set_bib_field b -join authority.control_set_bib_field_metabib_field_map map on (b.id = map.bib_field) -join config.metabib_field idx on (map.metabib_field = idx.id) -order by b.tag; - --- and fix bib field mapping if necessasry -UPDATE authority.control_set_bib_field_metabib_field_map map -SET metabib_field = cmf.id -FROM config.metabib_field cmf -WHERE cmf.field_class = 'subject' AND cmf.name= 'temporal_browse' -AND map.bib_field IN ( - SELECT b.id - FROM authority.control_set_bib_field b - JOIN authority.control_set_authority_field a - ON (b.authority_field = a.id) - AND a.tag = '148' -) -AND map.metabib_field IN ( - SELECT id - FROM config.metabib_field - WHERE field_class = 'subject' AND name = 'geographic_browse' -); -UPDATE authority.control_set_bib_field_metabib_field_map map -SET metabib_field = cmf.id -FROM config.metabib_field cmf -WHERE cmf.field_class = 'subject' AND cmf.name= 'geographic_browse' -AND map.bib_field IN ( - SELECT b.id - FROM authority.control_set_bib_field b - JOIN authority.control_set_authority_field a - ON (b.authority_field = a.id) - AND a.tag = '151' -) -AND map.metabib_field IN ( - SELECT id - FROM config.metabib_field - WHERE field_class = 'subject' AND name = 'temporal_browse' -); - -\qecho Verify that bib subject fields appear to be mapped to -\qecho to correct browse indexes -SELECT b.id, b.tag, idx.field_class, idx.name -FROM authority.control_set_bib_field b -JOIN authority.control_set_bib_field_metabib_field_map map ON (b.id = map.bib_field) -JOIN config.metabib_field idx ON (map.metabib_field = idx.id) -WHERE tag ~ '^6' -ORDER BY b.tag; - -COMMIT; - -\qecho This is a browse-only reingest of your bib records. It may take a while. -\qecho You may cancel now without losing the effect of the rest of the -\qecho upgrade script, and arrange the reingest later. -\qecho . -SELECT metabib.reingest_metabib_field_entries(id, TRUE, FALSE, TRUE) - FROM biblio.record_entry;