From: Bill Erickson Date: Fri, 21 Jun 2019 18:50:35 +0000 (-0400) Subject: JBAS-1832 Auth ingest happens last in 3.2 update X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=1ab6eab13cfc2ec4081827ea67ac08d431c9e1c0;p=working%2FEvergreen.git JBAS-1832 Auth ingest happens last in 3.2 update Signed-off-by: Bill Erickson --- diff --git a/KCLS/sql/schema/deploy/3.2-additions.sql b/KCLS/sql/schema/deploy/3.2-additions.sql index 5140d9d9fb..885368f9d6 100644 --- a/KCLS/sql/schema/deploy/3.2-additions.sql +++ b/KCLS/sql/schema/deploy/3.2-additions.sql @@ -264,64 +264,4 @@ SELECT CLOCK_TIMESTAMP(), 'Done rebuilding reporter.materialized_simple_record.. */ -SELECT CLOCK_TIMESTAMP(), 'Reingesting authority records'; - -BEGIN; --- wrap the setup in a transaction so the script will die of something --- in here fails. Then run main reingest sans transaction. - --- add the flag ingest.disable_authority_full_rec if it does not exist -DO $INSERT$ -BEGIN - IF evergreen.insert_on_deploy() THEN - INSERT INTO config.internal_flag (name, enabled) - SELECT 'ingest.disable_authority_full_rec', FALSE - WHERE NOT EXISTS (SELECT 1 FROM config.internal_flag - WHERE name = 'ingest.disable_authority_full_rec'); - END IF; -- insert_on_deploy -END $INSERT$; - - -CREATE TEMPORARY TABLE internal_flag_state AS - SELECT name, enabled - FROM config.internal_flag - WHERE name in ( - 'ingest.reingest.force_on_same_marc', - 'ingest.disable_authority_auto_update', - 'ingest.disable_authority_full_rec' - ); - -UPDATE config.internal_flag -SET enabled = TRUE -WHERE name in ( - 'ingest.reingest.force_on_same_marc', - 'ingest.disable_authority_auto_update', - 'ingest.disable_authority_full_rec' -); - -COMMIT; - --- execute the main reingest outside of a transaction - -ALTER TABLE authority.record_entry DISABLE TRIGGER a_marcxml_is_well_formed; -ALTER TABLE authority.record_entry DISABLE TRIGGER b_maintain_901; -ALTER TABLE authority.record_entry DISABLE TRIGGER c_maintain_control_numbers; -ALTER TABLE authority.record_entry DISABLE TRIGGER map_thesaurus_to_control_set; - -SELECT CLOCK_TIMESTAMP(), 'Authority re-ingest started...'; - -UPDATE authority.record_entry SET id = id WHERE NOT DELETED; - -ALTER TABLE authority.record_entry ENABLE TRIGGER a_marcxml_is_well_formed; -ALTER TABLE authority.record_entry ENABLE TRIGGER b_maintain_901; -ALTER TABLE authority.record_entry ENABLE TRIGGER c_maintain_control_numbers; -ALTER TABLE authority.record_entry ENABLE TRIGGER map_thesaurus_to_control_set; - --- and restore -UPDATE config.internal_flag a -SET enabled = b.enabled -FROM internal_flag_state b -WHERE a.name = b.name; - -SELECT CLOCK_TIMESTAMP(), 'Done reingesting authority records'; diff --git a/KCLS/sql/schema/deploy/3.2-auth-reingest.sql b/KCLS/sql/schema/deploy/3.2-auth-reingest.sql new file mode 100644 index 0000000000..b533ea7226 --- /dev/null +++ b/KCLS/sql/schema/deploy/3.2-auth-reingest.sql @@ -0,0 +1,66 @@ +-- Deploy kcls-evergreen:3.2-auth-reingest to pg +-- requires: cat-215-acqlimad-sortkey + +SET STATEMENT_TIMEOUT = 0; + +SELECT CLOCK_TIMESTAMP(), 'Reingesting authority records'; + +BEGIN; +-- wrap the setup in a transaction so the script will die of something +-- in here fails. Then run main reingest sans transaction. + +-- add the flag ingest.disable_authority_full_rec if it does not exist +DO $INSERT$ +BEGIN + IF evergreen.insert_on_deploy() THEN + INSERT INTO config.internal_flag (name, enabled) + SELECT 'ingest.disable_authority_full_rec', FALSE + WHERE NOT EXISTS (SELECT 1 FROM config.internal_flag + WHERE name = 'ingest.disable_authority_full_rec'); + END IF; -- insert_on_deploy +END $INSERT$; + + +CREATE TEMPORARY TABLE internal_flag_state AS + SELECT name, enabled + FROM config.internal_flag + WHERE name in ( + 'ingest.reingest.force_on_same_marc', + 'ingest.disable_authority_auto_update', + 'ingest.disable_authority_full_rec' + ); + +UPDATE config.internal_flag +SET enabled = TRUE +WHERE name in ( + 'ingest.reingest.force_on_same_marc', + 'ingest.disable_authority_auto_update', + 'ingest.disable_authority_full_rec' +); + +COMMIT; + +-- execute the main reingest outside of a transaction + +ALTER TABLE authority.record_entry DISABLE TRIGGER a_marcxml_is_well_formed; +ALTER TABLE authority.record_entry DISABLE TRIGGER b_maintain_901; +ALTER TABLE authority.record_entry DISABLE TRIGGER c_maintain_control_numbers; +ALTER TABLE authority.record_entry DISABLE TRIGGER map_thesaurus_to_control_set; + +SELECT CLOCK_TIMESTAMP(), 'Authority re-ingest started...'; + +UPDATE authority.record_entry SET id = id WHERE NOT DELETED; + +ALTER TABLE authority.record_entry ENABLE TRIGGER a_marcxml_is_well_formed; +ALTER TABLE authority.record_entry ENABLE TRIGGER b_maintain_901; +ALTER TABLE authority.record_entry ENABLE TRIGGER c_maintain_control_numbers; +ALTER TABLE authority.record_entry ENABLE TRIGGER map_thesaurus_to_control_set; + +-- and restore +UPDATE config.internal_flag a +SET enabled = b.enabled +FROM internal_flag_state b +WHERE a.name = b.name; + +SELECT CLOCK_TIMESTAMP(), 'Done reingesting authority records'; + diff --git a/KCLS/sql/schema/revert/3.2-auth-reingest.sql b/KCLS/sql/schema/revert/3.2-auth-reingest.sql new file mode 100644 index 0000000000..e4f9a3bc18 --- /dev/null +++ b/KCLS/sql/schema/revert/3.2-auth-reingest.sql @@ -0,0 +1,7 @@ +-- Revert kcls-evergreen:3.2-auth-reingest from pg + +BEGIN; + +-- XXX Add DDLs here. + +COMMIT; diff --git a/KCLS/sql/schema/sqitch.plan b/KCLS/sql/schema/sqitch.plan index f683e9ac8d..2987bd786a 100644 --- a/KCLS/sql/schema/sqitch.plan +++ b/KCLS/sql/schema/sqitch.plan @@ -89,3 +89,4 @@ stock-browse-cleanup [stock-browse-schema] 2018-10-03T18:05:49Z Bill Erickson,,, 3.2-additions [3.2-data-billing-timestamps] 2018-12-07T14:56:18Z berick # Additional 3.2 data, etc. tweaks 3.2-post-base-schema [3.2-additions] 2019-03-21T20:11:40Z berick # 3.2 bug fixes post original upgrade script cat-215-acqlimad-sortkey 2019-05-02T15:46:20Z opensrf # Add description_sortkey column to acq.lineitem_marc_attr_definitions +3.2-auth-reingest [cat-215-acqlimad-sortkey] 2019-06-21T18:48:23Z berick # Reingest authority records