Per Robert Soulliere, it can be necessary in some cases to clean out bad
authorsenator <senator@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 24 Feb 2011 15:35:12 +0000 (15:35 +0000)
committersenator <senator@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 24 Feb 2011 15:35:12 +0000 (15:35 +0000)
data from action.reservation_transit_copy before applying the missing
fkeys to said table.

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

git-svn-id: svn://svn.open-ils.org/ILS/trunk@19528 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/sql/Pg/1.6.1-2.0-upgrade-db.sql

index 9d8e8c4..6fb8039 100644 (file)
@@ -18793,6 +18793,17 @@ ALTER TABLE acq.provider_contact
 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: