From: Bill Erickson Date: Wed, 30 Dec 2015 16:46:27 +0000 (-0500) Subject: JBAS-944 Move auth updates to 2ndry transaction X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=91121365abf57d7731a03aa8752e4dfff0170cf1;p=working%2FEvergreen.git JBAS-944 Move auth updates to 2ndry transaction Signed-off-by: Bill Erickson --- diff --git a/KCLS/sql/schema/deploy/2.5-to-2.7-upgrade.sql b/KCLS/sql/schema/deploy/2.5-to-2.7-upgrade.sql index f3c23d38d9..ed9f1c27b8 100644 --- a/KCLS/sql/schema/deploy/2.5-to-2.7-upgrade.sql +++ b/KCLS/sql/schema/deploy/2.5-to-2.7-upgrade.sql @@ -3,11 +3,13 @@ \set ON_ERROR_STOP on +/* ALTER TABLE authority.record_entry DISABLE TRIGGER a_marcxml_is_well_formed; ALTER TABLE authority.record_entry DISABLE TRIGGER aaa_auth_ingest_or_delete; 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; +*/ BEGIN; @@ -5502,6 +5504,9 @@ SELECT evergreen.upgrade_deps_block_check('0875', :eg_version); ALTER TABLE authority.record_entry ADD COLUMN heading TEXT, ADD COLUMN simple_heading TEXT; DROP INDEX IF EXISTS authority.unique_by_heading_and_thesaurus; + +-- auth updates and indexes recreated in secondary transaction. +/* DROP INDEX IF EXISTS authority.by_heading_and_thesaurus; DROP INDEX IF EXISTS authority.by_heading; @@ -5513,6 +5518,8 @@ UPDATE authority.record_entry CREATE INDEX by_heading_and_thesaurus ON authority.record_entry (heading) WHERE deleted IS FALSE or deleted = FALSE; CREATE INDEX by_heading ON authority.record_entry (simple_heading) WHERE deleted IS FALSE or deleted = FALSE; +*/ + -- Add the trigger CREATE OR REPLACE FUNCTION authority.normalize_heading_for_upsert () RETURNS TRIGGER AS $f$ BEGIN @@ -5836,11 +5843,13 @@ END; $$ LANGUAGE PLPGSQL; -- re-enable the triggers we disabled before starting the transaction +/* ALTER TABLE authority.record_entry ENABLE TRIGGER a_marcxml_is_well_formed; ALTER TABLE authority.record_entry ENABLE TRIGGER aaa_auth_ingest_or_delete; 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; +*/ -- TODO RECREATE reporter.classic_current_circ; @@ -7858,14 +7867,17 @@ $func$ LANGUAGE PLPGSQL STABLE STRICT; -- fix heading and simple_headings columns without -- causing a full authority reingest +/* ALTER TABLE authority.record_entry DISABLE TRIGGER a_marcxml_is_well_formed; ALTER TABLE authority.record_entry DISABLE TRIGGER aaa_auth_ingest_or_delete; 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 COUNT(*) FROM authority.record_entry WHERE heading LIKE 'NOHEADING%'; UPDATE authority.record_entry SET id = id WHERE heading LIKE 'NOHEADING%'; - +SELECT COUNT(*) FROM authority.record_entry WHERE heading LIKE 'NOHEADING%'; +*/ -- check whether patch can be applied SELECT evergreen.upgrade_deps_block_check('0906', :eg_version); @@ -8880,13 +8892,4 @@ UPDATE authority.control_set_authority_field SET sf_list = REGEXP_REPLACE( sf_li COMMIT; --- These need to happen outside of the transaction to avoid this: --- ERROR: cannot ALTER TABLE "record_entry" because it has pending trigger --- events -ALTER TABLE authority.record_entry ENABLE TRIGGER a_marcxml_is_well_formed; -ALTER TABLE authority.record_entry ENABLE TRIGGER aaa_auth_ingest_or_delete; -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; - diff --git a/KCLS/sql/schema/deploy/2.7-auth-reingest.sql b/KCLS/sql/schema/deploy/2.7-auth-reingest.sql new file mode 100644 index 0000000000..3e90efe189 --- /dev/null +++ b/KCLS/sql/schema/deploy/2.7-auth-reingest.sql @@ -0,0 +1,29 @@ +-- Deploy kcls-evergreen:2.7-auth-reingest to pg +-- requires: 2.5-to-2.7-upgrade + +BEGIN; + +ALTER TABLE authority.record_entry DISABLE TRIGGER a_marcxml_is_well_formed; +ALTER TABLE authority.record_entry DISABLE TRIGGER aaa_auth_ingest_or_delete; +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; + +DROP INDEX IF EXISTS authority.by_heading_and_thesaurus; +DROP INDEX IF EXISTS authority.by_heading; + +-- build the new heading and simple_heading values +UPDATE authority.record_entry SET id = id; + +CREATE INDEX by_heading_and_thesaurus ON authority.record_entry (heading) + WHERE deleted IS FALSE or deleted = FALSE; +CREATE INDEX by_heading ON authority.record_entry (simple_heading) + WHERE deleted IS FALSE or deleted = FALSE; + +ALTER TABLE authority.record_entry ENABLE TRIGGER a_marcxml_is_well_formed; +ALTER TABLE authority.record_entry ENABLE TRIGGER aaa_auth_ingest_or_delete; +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; + +COMMIT; diff --git a/KCLS/sql/schema/revert/2.7-auth-reingest.sql b/KCLS/sql/schema/revert/2.7-auth-reingest.sql new file mode 100644 index 0000000000..e4124240ab --- /dev/null +++ b/KCLS/sql/schema/revert/2.7-auth-reingest.sql @@ -0,0 +1,7 @@ +-- Revert kcls-evergreen:2.7-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 fdd6aacd42..5b4533c296 100644 --- a/KCLS/sql/schema/sqitch.plan +++ b/KCLS/sql/schema/sqitch.plan @@ -17,3 +17,4 @@ blanket-po-print-template [student-groups] 2015-10-12T15:38:31Z Bill Erickson # Minor PO print template repairs dob-as-date [student-groups] 2015-10-05T14:17:54Z Bill Erickson # Store DoB as date 2.5-to-2.7-upgrade [student-groups] 2015-10-15T20:40:14Z Bill Erickson # 2.5 to 2.7 Upgrade +2.7-auth-reingest [2.5-to-2.7-upgrade] 2015-12-30T16:25:38Z Bill Erickson # Reingest authority records after 2.7 update diff --git a/KCLS/sql/schema/verify/2.7-auth-reingest.sql b/KCLS/sql/schema/verify/2.7-auth-reingest.sql new file mode 100644 index 0000000000..ee751361b9 --- /dev/null +++ b/KCLS/sql/schema/verify/2.7-auth-reingest.sql @@ -0,0 +1,7 @@ +-- Verify kcls-evergreen:2.7-auth-reingest on pg + +BEGIN; + +-- XXX Add verifications here. + +ROLLBACK;