*/
-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';
--- /dev/null
+-- 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';
+
--- /dev/null
+-- Revert kcls-evergreen:3.2-auth-reingest from pg
+
+BEGIN;
+
+-- XXX Add DDLs here.
+
+COMMIT;
3.2-additions [3.2-data-billing-timestamps] 2018-12-07T14:56:18Z berick <berick@kcls-dev> # Additional 3.2 data, etc. tweaks
3.2-post-base-schema [3.2-additions] 2019-03-21T20:11:40Z berick <berick@kcls-dev> # 3.2 bug fixes post original upgrade script
cat-215-acqlimad-sortkey 2019-05-02T15:46:20Z opensrf <opensrf@kcls-greenlandic> # Add description_sortkey column to acq.lineitem_marc_attr_definitions
+3.2-auth-reingest [cat-215-acqlimad-sortkey] 2019-06-21T18:48:23Z berick <berick@kcls-dev> # Reingest authority records