[open-ils-commits] r19530 - branches/rel_2_1/Open-ILS/src/sql/Pg (senator)

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Feb 24 10:36:20 EST 2011


Author: senator
Date: 2011-02-24 10:36:18 -0500 (Thu, 24 Feb 2011)
New Revision: 19530

Modified:
   branches/rel_2_1/Open-ILS/src/sql/Pg/1.6.1-2.0-upgrade-db.sql
Log:
Per Robert Soulliere, it can be necessary in some cases to clean out bad 
data from action.reservation_transit_copy before applying the missing
fkeys to said table.

https://bugs.launchpad.net/evergreen/+bug/721450



Modified: branches/rel_2_1/Open-ILS/src/sql/Pg/1.6.1-2.0-upgrade-db.sql
===================================================================
--- branches/rel_2_1/Open-ILS/src/sql/Pg/1.6.1-2.0-upgrade-db.sql	2011-02-24 15:35:51 UTC (rev 19529)
+++ branches/rel_2_1/Open-ILS/src/sql/Pg/1.6.1-2.0-upgrade-db.sql	2011-02-24 15:36:18 UTC (rev 19530)
@@ -18793,6 +18793,17 @@
 ALTER TABLE actor.stat_cat
 	ADD COLUMN usr_summary BOOL NOT NULL DEFAULT FALSE;
 
+-- Per Robert Soulliere, it can be necessary in some cases to clean out bad
+-- data from action.reservation_transit_copy before applying the missing
+-- fkeys below.
+-- https://bugs.launchpad.net/evergreen/+bug/721450
+DELETE FROM action.reservation_transit_copy
+    WHERE target_copy NOT IN (SELECT id FROM booking.resource);
+-- In the same spirit as the above delete, this can only fix bad data.
+UPDATE action.reservation_transit_copy
+    SET reservation = NULL
+    WHERE reservation NOT IN (SELECT id FROM booking.reservation);
+
 -- Recreate some foreign keys that were somehow dropped, probably
 -- by some kind of cascade from an inherited table:
 



More information about the open-ils-commits mailing list