[open-ils-commits] r15780 - in trunk/Open-ILS/src/sql/Pg: . upgrade (scottmk)
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Mar 10 17:30:10 EST 2010
Author: scottmk
Date: 2010-03-10 17:30:04 -0500 (Wed, 10 Mar 2010)
New Revision: 15780
Added:
trunk/Open-ILS/src/sql/Pg/upgrade/0186.schema.acq-on-delete-li.sql
Modified:
trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
trunk/Open-ILS/src/sql/Pg/200.schema.acq.sql
Log:
Add "ON DELETE CASCADE" clauses to foreign keys pointing to
acq.lineitem, from the following tables:
acq.distribution_formula_application
acq.lineitem_attr
acq.lineitem_detail
acq.lineitem_note
M Open-ILS/src/sql/Pg/200.schema.acq.sql
M Open-ILS/src/sql/Pg/002.schema.config.sql
A Open-ILS/src/sql/Pg/upgrade/0186.schema.acq-on-delete-li.sql
Modified: trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2010-03-10 20:25:55 UTC (rev 15779)
+++ trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2010-03-10 22:30:04 UTC (rev 15780)
@@ -51,7 +51,7 @@
install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
);
-INSERT INTO config.upgrade_log (version) VALUES ('0185'); -- Scott McKellar
+INSERT INTO config.upgrade_log (version) VALUES ('0186'); -- Scott McKellar
CREATE TABLE config.bib_source (
id SERIAL PRIMARY KEY,
Modified: trunk/Open-ILS/src/sql/Pg/200.schema.acq.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/200.schema.acq.sql 2010-03-10 20:25:55 UTC (rev 15779)
+++ trunk/Open-ILS/src/sql/Pg/200.schema.acq.sql 2010-03-10 22:30:04 UTC (rev 15780)
@@ -475,7 +475,7 @@
CREATE TABLE acq.lineitem_note (
id SERIAL PRIMARY KEY,
- lineitem INT NOT NULL REFERENCES acq.lineitem (id) DEFERRABLE INITIALLY DEFERRED,
+ lineitem INT NOT NULL REFERENCES acq.lineitem (id) ON CASCADE DELETE DEFERRABLE INITIALLY DEFERRED,
creator INT NOT NULL REFERENCES actor.usr (id) DEFERRABLE INITIALLY DEFERRED,
editor INT NOT NULL REFERENCES actor.usr (id) DEFERRABLE INITIALLY DEFERRED,
create_time TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
@@ -490,7 +490,7 @@
CREATE TABLE acq.lineitem_detail (
id BIGSERIAL PRIMARY KEY,
- lineitem INT NOT NULL REFERENCES acq.lineitem (id) DEFERRABLE INITIALLY DEFERRED,
+ lineitem INT NOT NULL REFERENCES acq.lineitem (id) ON CASCADE DELETE DEFERRABLE INITIALLY DEFERRED,
fund INT REFERENCES acq.fund (id) DEFERRABLE INITIALLY DEFERRED,
fund_debit INT REFERENCES acq.fund_debit (id) DEFERRABLE INITIALLY DEFERRED,
eg_copy_id BIGINT REFERENCES asset.copy (id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED,
@@ -544,7 +544,7 @@
CREATE TABLE acq.lineitem_attr (
id BIGSERIAL PRIMARY KEY,
definition BIGINT NOT NULL,
- lineitem BIGINT NOT NULL REFERENCES acq.lineitem (id) DEFERRABLE INITIALLY DEFERRED,
+ lineitem BIGINT NOT NULL REFERENCES acq.lineitem (id) ON CASCADE DELETE DEFERRABLE INITIALLY DEFERRED,
attr_type TEXT NOT NULL,
attr_name TEXT NOT NULL,
attr_value TEXT NOT NULL
@@ -604,7 +604,7 @@
formula INT NOT NULL
REFERENCES acq.distribution_formula(id) DEFERRABLE INITIALLY DEFERRED,
lineitem INT NOT NULL
- REFERENCES acq.lineitem(id) DEFERRABLE INITIALLY DEFERRED
+ REFERENCES acq.lineitem(id) ON CASCADE DELETE DEFERRABLE INITIALLY DEFERRED
);
CREATE INDEX acqdfa_df_idx
Added: trunk/Open-ILS/src/sql/Pg/upgrade/0186.schema.acq-on-delete-li.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/upgrade/0186.schema.acq-on-delete-li.sql (rev 0)
+++ trunk/Open-ILS/src/sql/Pg/upgrade/0186.schema.acq-on-delete-li.sql 2010-03-10 22:30:04 UTC (rev 15780)
@@ -0,0 +1,37 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0186'); -- Scott McKellar
+
+ALTER TABLE acq.distribution_formula_application
+ DROP CONSTRAINT distribution_formula_application_lineitem_fkey;
+
+ALTER TABLE acq.distribution_formula_application
+ ADD FOREIGN KEY (lineitem) REFERENCES acq.lineitem( id )
+ ON DELETE CASCADE
+ DEFERRABLE INITIALLY DEFERRED;
+
+ALTER TABLE acq.lineitem_attr
+ DROP CONSTRAINT lineitem_attr_lineitem_fkey;
+
+ALTER TABLE acq.lineitem_attr
+ ADD FOREIGN KEY (lineitem) REFERENCES acq.lineitem( id )
+ ON DELETE CASCADE
+ DEFERRABLE INITIALLY DEFERRED;
+
+ALTER TABLE acq.lineitem_detail
+ DROP CONSTRAINT lineitem_detail_lineitem_fkey;
+
+ALTER TABLE acq.lineitem_detail
+ ADD FOREIGN KEY (lineitem) REFERENCES acq.lineitem( id )
+ ON DELETE CASCADE
+ DEFERRABLE INITIALLY DEFERRED;
+
+ALTER TABLE acq.lineitem_note
+ DROP CONSTRAINT lineitem_note_lineitem_fkey;
+
+ALTER TABLE acq.lineitem_note
+ ADD FOREIGN KEY (lineitem) REFERENCES acq.lineitem( id )
+ ON DELETE CASCADE
+ DEFERRABLE INITIALLY DEFERRED;
+
+COMMIT;
More information about the open-ils-commits
mailing list