JBAS-1832 Auth ingest happens last in 3.2 update
authorBill Erickson <berickxx@gmail.com>
Fri, 21 Jun 2019 18:50:35 +0000 (14:50 -0400)
committerBill Erickson <berickxx@gmail.com>
Fri, 21 Jun 2019 18:50:35 +0000 (14:50 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
KCLS/sql/schema/deploy/3.2-additions.sql
KCLS/sql/schema/deploy/3.2-auth-reingest.sql [new file with mode: 0644]
KCLS/sql/schema/revert/3.2-auth-reingest.sql [new file with mode: 0644]
KCLS/sql/schema/sqitch.plan

index 5140d9d..885368f 100644 (file)
@@ -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 (file)
index 0000000..b533ea7
--- /dev/null
@@ -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 (file)
index 0000000..e4f9a3b
--- /dev/null
@@ -0,0 +1,7 @@
+-- Revert kcls-evergreen:3.2-auth-reingest from pg
+
+BEGIN;
+
+-- XXX Add DDLs here.
+
+COMMIT;
index f683e9a..2987bd7 100644 (file)
@@ -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 <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