From 77b750d4163897d3e8105388d352e75e19e803fc Mon Sep 17 00:00:00 2001 From: Dan Scott Date: Thu, 27 Jun 2013 09:46:55 -0400 Subject: [PATCH] Avoid 0788 duplication from 2.3 failure Recent installs of 2.3, or upgrades during 2.3, will have introduced 0788 already into the upgrade process -- meaning that the 2.3-2.4.0 script will rollback the entire transaction if it hits the duplicated 0788. Instead, move 0788 into its own transaction to increase the chances that the 2.3-2.4.0 script will work for sites that stay up to date or that recently installed Evergreen. Signed-off-by: Dan Scott Signed-off-by: Mike Rylander --- .../version-upgrade/2.3-2.4.0-upgrade-db.sql | 76 ++++++++++--------- 1 file changed, 41 insertions(+), 35 deletions(-) diff --git a/Open-ILS/src/sql/Pg/version-upgrade/2.3-2.4.0-upgrade-db.sql b/Open-ILS/src/sql/Pg/version-upgrade/2.3-2.4.0-upgrade-db.sql index 6c172a9bf8..6d920296ae 100644 --- a/Open-ILS/src/sql/Pg/version-upgrade/2.3-2.4.0-upgrade-db.sql +++ b/Open-ILS/src/sql/Pg/version-upgrade/2.3-2.4.0-upgrade-db.sql @@ -3367,41 +3367,6 @@ END; $func$ LANGUAGE PLPGSQL; - -SELECT evergreen.upgrade_deps_block_check('0788', :eg_version); - --- New view including 264 as a potential tag for publisher and pubdate -CREATE OR REPLACE VIEW reporter.old_super_simple_record AS -SELECT r.id, - r.fingerprint, - r.quality, - r.tcn_source, - r.tcn_value, - FIRST(title.value) AS title, - FIRST(author.value) AS author, - ARRAY_TO_STRING(ARRAY_ACCUM( DISTINCT publisher.value), ', ') AS publisher, - ARRAY_TO_STRING(ARRAY_ACCUM( DISTINCT SUBSTRING(pubdate.value FROM $$\d+$$) ), ', ') AS pubdate, - ARRAY_ACCUM( DISTINCT REPLACE(SUBSTRING(isbn.value FROM $$^\S+$$), '-', '') ) AS isbn, - ARRAY_ACCUM( DISTINCT REGEXP_REPLACE(issn.value, E'^\\S*(\\d{4})[-\\s](\\d{3,4}x?)', E'\\1 \\2') ) AS issn - FROM biblio.record_entry r - LEFT JOIN metabib.full_rec title ON (r.id = title.record AND title.tag = '245' AND title.subfield = 'a') - LEFT JOIN metabib.full_rec author ON (r.id = author.record AND author.tag IN ('100','110','111') AND author.subfield = 'a') - LEFT JOIN metabib.full_rec publisher ON (r.id = publisher.record AND (publisher.tag = '260' OR (publisher.tag = '264' AND publisher.ind2 = '1')) AND publisher.subfield = 'b') - LEFT JOIN metabib.full_rec pubdate ON (r.id = pubdate.record AND (pubdate.tag = '260' OR (pubdate.tag = '264' AND pubdate.ind2 = '1')) AND pubdate.subfield = 'c') - LEFT JOIN metabib.full_rec isbn ON (r.id = isbn.record AND isbn.tag IN ('024', '020') AND isbn.subfield IN ('a','z')) - LEFT JOIN metabib.full_rec issn ON (r.id = issn.record AND issn.tag = '022' AND issn.subfield = 'a') - GROUP BY 1,2,3,4,5; - --- Update reporter.materialized_simple_record with new 264-based values for publisher and pubdate -DELETE FROM reporter.materialized_simple_record WHERE id IN ( - SELECT DISTINCT record FROM metabib.full_rec WHERE tag = '264' AND subfield IN ('b', 'c') -); - -INSERT INTO reporter.materialized_simple_record - SELECT DISTINCT rossr.* FROM reporter.old_super_simple_record rossr INNER JOIN metabib.full_rec mfr ON mfr.record = rossr.id - WHERE mfr.tag = '264' AND mfr.subfield IN ('b', 'c') -; - SELECT evergreen.upgrade_deps_block_check('0789', :eg_version); SELECT evergreen.upgrade_deps_block_check('0790', :eg_version); @@ -3986,6 +3951,47 @@ WHERE name = 'Traditional with Holds-go-home' AND COMMIT; +\qecho 'These are from 0788, and should be run in their own transaction' +\qecho 'If these fail due to 0788 already having been applied during' +\qecho '2.3 upgrades, that is good; you have just saved yourself a lot of time.' +\qecho + +BEGIN; +SELECT evergreen.upgrade_deps_block_check('0788', :eg_version); + +-- New view including 264 as a potential tag for publisher and pubdate +CREATE OR REPLACE VIEW reporter.old_super_simple_record AS +SELECT r.id, + r.fingerprint, + r.quality, + r.tcn_source, + r.tcn_value, + FIRST(title.value) AS title, + FIRST(author.value) AS author, + ARRAY_TO_STRING(ARRAY_ACCUM( DISTINCT publisher.value), ', ') AS publisher, + ARRAY_TO_STRING(ARRAY_ACCUM( DISTINCT SUBSTRING(pubdate.value FROM $$\d+$$) ), ', ') AS pubdate, + ARRAY_ACCUM( DISTINCT REPLACE(SUBSTRING(isbn.value FROM $$^\S+$$), '-', '') ) AS isbn, + ARRAY_ACCUM( DISTINCT REGEXP_REPLACE(issn.value, E'^\\S*(\\d{4})[-\\s](\\d{3,4}x?)', E'\\1 \\2') ) AS issn + FROM biblio.record_entry r + LEFT JOIN metabib.full_rec title ON (r.id = title.record AND title.tag = '245' AND title.subfield = 'a') + LEFT JOIN metabib.full_rec author ON (r.id = author.record AND author.tag IN ('100','110','111') AND author.subfield = 'a') + LEFT JOIN metabib.full_rec publisher ON (r.id = publisher.record AND (publisher.tag = '260' OR (publisher.tag = '264' AND publisher.ind2 = '1')) AND publisher.subfield = 'b') + LEFT JOIN metabib.full_rec pubdate ON (r.id = pubdate.record AND (pubdate.tag = '260' OR (pubdate.tag = '264' AND pubdate.ind2 = '1')) AND pubdate.subfield = 'c') + LEFT JOIN metabib.full_rec isbn ON (r.id = isbn.record AND isbn.tag IN ('024', '020') AND isbn.subfield IN ('a','z')) + LEFT JOIN metabib.full_rec issn ON (r.id = issn.record AND issn.tag = '022' AND issn.subfield = 'a') + GROUP BY 1,2,3,4,5; + +-- Update reporter.materialized_simple_record with new 264-based values for publisher and pubdate +DELETE FROM reporter.materialized_simple_record WHERE id IN ( + SELECT DISTINCT record FROM metabib.full_rec WHERE tag = '264' AND subfield IN ('b', 'c') +); + +INSERT INTO reporter.materialized_simple_record + SELECT DISTINCT rossr.* FROM reporter.old_super_simple_record rossr INNER JOIN metabib.full_rec mfr ON mfr.record = rossr.id + WHERE mfr.tag = '264' AND mfr.subfield IN ('b', 'c') +; +COMMIT; + -- These are from 0789, and can and should be run outside of a transaction CREATE TEXT SEARCH CONFIGURATION title ( COPY = english_nostop ); CREATE TEXT SEARCH CONFIGURATION author ( COPY = english_nostop ); -- 2.43.2