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,
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')),
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 (
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)
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
);
--- /dev/null
+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;
--- /dev/null
+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;