From d4b34797cc94fbe2acf54ccaea4ed481ee861f13 Mon Sep 17 00:00:00 2001 From: Dan Wells Date: Thu, 10 Oct 2013 15:54:40 -0400 Subject: [PATCH] Adding 0842, 0843 to help with 0841 deficiencies A clean backport of 0841 was not possible due to partial schema differences in the upgrade. While we may have planned ahead better, add 0842 just for 2_3 upgraders which ends up being a no-op for 2_4, and adds ON UPDATE CASCADE for 2_5. Also, for similar but additional reasons, add 0843, which serves two purposes: 1) add ON UPDATE CASCADE to the rest for those upgrading 2_5/master 2) alter config.z3950_index_field_map for those upgrading from 2_4 and previous (other lines are no-ops in this case) Signed-off-by: Dan Wells Signed-off-by: Remington Steed --- Open-ILS/src/sql/Pg/002.schema.config.sql | 8 ++++---- Open-ILS/src/sql/Pg/030.schema.metabib.sql | 2 +- ...a.redo_config_metabib_field_sequence_2_3_to_2_4.sql | 11 +++++++++++ ...3.schema.redo_config_metabib_field_sequence_2_5.sql | 18 ++++++++++++++++++ 4 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/0842.schema.redo_config_metabib_field_sequence_2_3_to_2_4.sql create mode 100644 Open-ILS/src/sql/Pg/upgrade/0843.schema.redo_config_metabib_field_sequence_2_5.sql diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index bed55d7787..c80854e933 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -91,7 +91,7 @@ CREATE TRIGGER no_overlapping_deps BEFORE INSERT OR UPDATE ON config.db_patch_dependencies FOR EACH ROW EXECUTE PROCEDURE evergreen.array_overlap_check ('deprecates'); -INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0841', :eg_version); -- dbwells/senator +INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0843', :eg_version); -- dbwells/rsteed CREATE TABLE config.bib_source ( id SERIAL PRIMARY KEY, @@ -239,7 +239,7 @@ $$; CREATE TABLE config.metabib_field_ts_map ( id SERIAL PRIMARY KEY, - metabib_field INT NOT NULL REFERENCES config.metabib_field (id) DEFERRABLE INITIALLY DEFERRED, + metabib_field INT NOT NULL REFERENCES config.metabib_field (id) ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED, ts_config TEXT NOT NULL REFERENCES config.ts_config_list (id), active BOOL NOT NULL DEFAULT TRUE, index_weight CHAR(1) NOT NULL DEFAULT 'C' CHECK (index_weight IN ('A','B','C','D')), @@ -256,7 +256,7 @@ $$; CREATE TABLE config.metabib_search_alias ( alias TEXT PRIMARY KEY, field_class TEXT NOT NULL REFERENCES config.metabib_class (name), - field INT REFERENCES config.metabib_field (id) DEFERRABLE INITIALLY DEFERRED + field INT REFERENCES config.metabib_field (id) ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED ); CREATE TABLE config.non_cataloged_type ( @@ -1056,7 +1056,7 @@ $$; CREATE TABLE config.z3950_index_field_map ( id SERIAL PRIMARY KEY, label TEXT NOT NULL, -- i18n - metabib_field INTEGER REFERENCES config.metabib_field(id) DEFERRABLE INITIALLY DEFERRED, + metabib_field INTEGER REFERENCES config.metabib_field(id) ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED, record_attr TEXT REFERENCES config.record_attr_definition(name), z3950_attr INTEGER REFERENCES config.z3950_attr(id), z3950_attr_type TEXT,-- REFERENCES config.z3950_attr(name) diff --git a/Open-ILS/src/sql/Pg/030.schema.metabib.sql b/Open-ILS/src/sql/Pg/030.schema.metabib.sql index 73b30ea735..a0ae451b1d 100644 --- a/Open-ILS/src/sql/Pg/030.schema.metabib.sql +++ b/Open-ILS/src/sql/Pg/030.schema.metabib.sql @@ -204,7 +204,7 @@ CREATE TRIGGER metabib_browse_entry_fti_trigger CREATE TABLE metabib.browse_entry_def_map ( id BIGSERIAL PRIMARY KEY, entry BIGINT REFERENCES metabib.browse_entry (id), - def INT REFERENCES config.metabib_field (id) DEFERRABLE INITIALLY DEFERRED, + def INT REFERENCES config.metabib_field (id) ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED, source BIGINT REFERENCES biblio.record_entry (id), authority BIGINT REFERENCES authority.record_entry (id) ON DELETE SET NULL ); diff --git a/Open-ILS/src/sql/Pg/upgrade/0842.schema.redo_config_metabib_field_sequence_2_3_to_2_4.sql b/Open-ILS/src/sql/Pg/upgrade/0842.schema.redo_config_metabib_field_sequence_2_3_to_2_4.sql new file mode 100644 index 0000000000..22aaaa420c --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/0842.schema.redo_config_metabib_field_sequence_2_3_to_2_4.sql @@ -0,0 +1,11 @@ +BEGIN; + +-- check whether patch can be applied +SELECT evergreen.upgrade_deps_block_check('0842', :eg_version); + +-- this upgrade is only for people coming from 2_3, and is a NO-OP for those on 2_4 +ALTER TABLE config.metabib_field_ts_map DROP CONSTRAINT metabib_field_ts_map_metabib_field_fkey; + +ALTER TABLE config.metabib_field_ts_map ADD CONSTRAINT metabib_field_ts_map_metabib_field_fkey FOREIGN KEY (metabib_field) REFERENCES config.metabib_field(id) ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; + +COMMIT; diff --git a/Open-ILS/src/sql/Pg/upgrade/0843.schema.redo_config_metabib_field_sequence_2_5.sql b/Open-ILS/src/sql/Pg/upgrade/0843.schema.redo_config_metabib_field_sequence_2_5.sql new file mode 100644 index 0000000000..acaf243e47 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/0843.schema.redo_config_metabib_field_sequence_2_5.sql @@ -0,0 +1,18 @@ +BEGIN; + +-- check whether patch can be applied +SELECT evergreen.upgrade_deps_block_check('0843', :eg_version); + +-- this upgrade file serves 2 purposes: +-- 1) add ON UPDATE CASCADE for those upgrading 2_5/master +-- 2) alter config.z3950_index_field_map for those upgrading from 2_4 and previous (other lines +-- are no-ops in this case) +ALTER TABLE config.metabib_search_alias DROP CONSTRAINT metabib_search_alias_field_fkey; +ALTER TABLE config.z3950_index_field_map DROP CONSTRAINT z3950_index_field_map_metabib_field_fkey; +ALTER TABLE metabib.browse_entry_def_map DROP CONSTRAINT browse_entry_def_map_def_fkey; + +ALTER TABLE config.metabib_search_alias ADD CONSTRAINT metabib_search_alias_field_fkey FOREIGN KEY (field) REFERENCES config.metabib_field(id) ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; +ALTER TABLE config.z3950_index_field_map ADD CONSTRAINT z3950_index_field_map_metabib_field_fkey FOREIGN KEY (metabib_field) REFERENCES config.metabib_field(id) ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; +ALTER TABLE metabib.browse_entry_def_map ADD CONSTRAINT browse_entry_def_map_def_fkey FOREIGN KEY (def) REFERENCES config.metabib_field(id) ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; + +COMMIT; -- 2.11.0