From: Bill Erickson Date: Wed, 13 Mar 2013 18:26:48 +0000 (-0400) Subject: LP 849008 : Cascade delete Z39.50 attributes X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=4454d116436ae9ed9e22cd3d127684cbc4ed2272;p=contrib%2FConifer.git LP 849008 : Cascade delete Z39.50 attributes Force deletion of Z39.50 attributes within the database when the Z39.50 source to which the attributes refer is deleted. Signed-off-by: Bill Erickson Signed-off-by: Mike Rylander --- diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index e578c0fab6..a7db50d477 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -505,7 +505,7 @@ $$; CREATE TABLE config.z3950_attr ( id SERIAL PRIMARY KEY, - source TEXT NOT NULL REFERENCES config.z3950_source (name) DEFERRABLE INITIALLY DEFERRED, + source TEXT NOT NULL REFERENCES config.z3950_source (name) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, name TEXT NOT NULL, label TEXT NOT NULL, code INT NOT NULL, diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.config_z3950_source_attr_cascade_delete.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.config_z3950_source_attr_cascade_delete.sql new file mode 100644 index 0000000000..9b99364911 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.config_z3950_source_attr_cascade_delete.sql @@ -0,0 +1,15 @@ + +BEGIN; + +SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version); + +ALTER TABLE config.z3950_attr + DROP CONSTRAINT z3950_attr_source_fkey, + ADD CONSTRAINT z3950_attr_source_fkey + FOREIGN KEY (source) + REFERENCES config.z3950_source(name) + ON UPDATE CASCADE + ON DELETE CASCADE + DEFERRABLE INITIALLY DEFERRED; + +COMMIT;