[open-ils-commits] r16910 - in trunk/Open-ILS/src/sql/Pg: . upgrade (gmc)
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon Jul 12 13:09:27 EDT 2010
Author: gmc
Date: 2010-07-12 13:09:23 -0400 (Mon, 12 Jul 2010)
New Revision: 16910
Added:
trunk/Open-ILS/src/sql/Pg/upgrade/0333.schema.protect_serial_unit_delete.sql
Modified:
trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
trunk/Open-ILS/src/sql/Pg/210.schema.serials.sql
Log:
protect against deletion of serial.unit rows
Rules are not inherited by child tables, so must
add one explicitly.
Signed-off-by: Galen Charlton <gmc at esilibrary.com>
Modified: trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2010-07-12 16:08:14 UTC (rev 16909)
+++ trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2010-07-12 17:09:23 UTC (rev 16910)
@@ -68,7 +68,7 @@
install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
);
-INSERT INTO config.upgrade_log (version) VALUES ('0332'); -- gmc
+INSERT INTO config.upgrade_log (version) VALUES ('0333'); -- gmc
CREATE TABLE config.bib_source (
id SERIAL PRIMARY KEY,
Modified: trunk/Open-ILS/src/sql/Pg/210.schema.serials.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/210.schema.serials.sql 2010-07-12 16:08:14 UTC (rev 16909)
+++ trunk/Open-ILS/src/sql/Pg/210.schema.serials.sql 2010-07-12 17:09:23 UTC (rev 16910)
@@ -162,6 +162,9 @@
ALTER TABLE serial.unit ADD PRIMARY KEY (id);
+-- must create this rule explicitly; it is not inherited from asset.copy
+CREATE RULE protect_serial_unit_delete AS ON DELETE TO serial.unit DO INSTEAD UPDATE serial.unit SET deleted = TRUE WHERE OLD.id = serial.unit.id;
+
CREATE TABLE serial.item (
id SERIAL PRIMARY KEY,
creator INT NOT NULL
Added: trunk/Open-ILS/src/sql/Pg/upgrade/0333.schema.protect_serial_unit_delete.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/upgrade/0333.schema.protect_serial_unit_delete.sql (rev 0)
+++ trunk/Open-ILS/src/sql/Pg/upgrade/0333.schema.protect_serial_unit_delete.sql 2010-07-12 17:09:23 UTC (rev 16910)
@@ -0,0 +1,8 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0333'); --gmc
+
+-- must create this rule explicitly; it is not inherited from asset.copy
+CREATE RULE protect_serial_unit_delete AS ON DELETE TO serial.unit DO INSTEAD UPDATE serial.unit SET deleted = TRUE WHERE OLD.id = serial.unit.id;
+
+COMMIT;
More information about the open-ils-commits
mailing list