From 7bdf53455c7940eb2b77c1049c99bfac6bbb10c7 Mon Sep 17 00:00:00 2001 From: miker Date: Wed, 17 Mar 2010 19:18:37 +0000 Subject: [PATCH] delete the metarecord link for "deleted" records git-svn-id: svn://svn.open-ils.org/ILS/trunk@15882 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/sql/Pg/002.schema.config.sql | 2 +- Open-ILS/src/sql/Pg/010.schema.biblio.sql | 2 +- Open-ILS/src/sql/Pg/upgrade/0199.schema.delete-metabib-link.sql | 8 ++++++++ 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/0199.schema.delete-metabib-link.sql diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index ea37dac076..0e78d5b16b 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -58,7 +58,7 @@ CREATE TABLE config.upgrade_log ( install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW() ); -INSERT INTO config.upgrade_log (version) VALUES ('0198'); -- Scott McKellar +INSERT INTO config.upgrade_log (version) VALUES ('0199'); -- miker CREATE TABLE config.bib_source ( id SERIAL PRIMARY KEY, diff --git a/Open-ILS/src/sql/Pg/010.schema.biblio.sql b/Open-ILS/src/sql/Pg/010.schema.biblio.sql index b171801360..00c82af9aa 100644 --- a/Open-ILS/src/sql/Pg/010.schema.biblio.sql +++ b/Open-ILS/src/sql/Pg/010.schema.biblio.sql @@ -48,7 +48,7 @@ CREATE INDEX biblio_record_entry_edit_date_idx ON biblio.record_entry ( edit_dat CREATE INDEX biblio_record_entry_fp_idx ON biblio.record_entry ( fingerprint ); CREATE UNIQUE INDEX biblio_record_unique_tcn ON biblio.record_entry (tcn_value) WHERE deleted IS FALSE; -CREATE RULE protect_bib_rec_delete AS ON DELETE TO biblio.record_entry DO INSTEAD UPDATE biblio.record_entry SET deleted = TRUE WHERE OLD.id = biblio.record_entry.id; +CREATE RULE protect_bib_rec_delete AS ON DELETE TO biblio.record_entry DO INSTEAD (UPDATE biblio.record_entry SET deleted = TRUE WHERE OLD.id = biblio.record_entry.id; DELETE FROM metabib.metarecord_source_map WHERE source = OLD.id); CREATE TABLE biblio.record_note ( diff --git a/Open-ILS/src/sql/Pg/upgrade/0199.schema.delete-metabib-link.sql b/Open-ILS/src/sql/Pg/upgrade/0199.schema.delete-metabib-link.sql new file mode 100644 index 0000000000..a497d1e146 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/0199.schema.delete-metabib-link.sql @@ -0,0 +1,8 @@ + +BEGIN; + +INSERT INTO config.upgrade_log (version) VALUES ('0199'); -- miker + +CREATE OR REPLACE RULE protect_bib_rec_delete AS ON DELETE TO biblio.record_entry DO INSTEAD (UPDATE biblio.record_entry SET deleted = TRUE WHERE OLD.id = biblio.record_entry.id; DELETE FROM metabib.metarecord_source_map WHERE source = OLD.id); + +COMMIT; -- 2.11.0