Stamping upgrade script for current_shelf_lib
authorMike Rylander <mrylander@gmail.com>
Mon, 9 Jan 2012 18:49:40 +0000 (13:49 -0500)
committerMike Rylander <mrylander@gmail.com>
Mon, 9 Jan 2012 18:49:40 +0000 (13:49 -0500)
Signed-off-by: Mike Rylander <mrylander@gmail.com>

Open-ILS/src/sql/Pg/002.schema.config.sql
Open-ILS/src/sql/Pg/upgrade/0664.schema.hold-current-shelf-lib.sql [new file with mode: 0644]
Open-ILS/src/sql/Pg/upgrade/XXXX.schema.hold-current-shelf-lib.sql [deleted file]

index c08457d..87e7150 100644 (file)
@@ -86,7 +86,7 @@ CREATE TRIGGER no_overlapping_deps
     BEFORE INSERT OR UPDATE ON config.db_patch_dependencies
     FOR EACH ROW EXECUTE PROCEDURE evergreen.array_overlap_check ('deprecates');
 
-INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0663', :eg_version); -- tsbere/dbs
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0664', :eg_version); -- berick/miker
 
 CREATE TABLE config.bib_source (
        id              SERIAL  PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/0664.schema.hold-current-shelf-lib.sql b/Open-ILS/src/sql/Pg/upgrade/0664.schema.hold-current-shelf-lib.sql
new file mode 100644 (file)
index 0000000..f46db93
--- /dev/null
@@ -0,0 +1,27 @@
+-- Evergreen DB patch 0664.schema.hold-current-shelf-lib.sql
+--
+--
+BEGIN;
+
+
+-- check whether patch can be applied
+SELECT evergreen.upgrade_deps_block_check('0664', :eg_version);
+
+-- add the new column
+ALTER TABLE action.hold_request ADD COLUMN current_shelf_lib 
+    INT REFERENCES actor.org_unit DEFERRABLE INITIALLY DEFERRED;
+
+-- set the value for current_shelf_lib on existing shelved holds
+UPDATE action.hold_request
+    SET current_shelf_lib = pickup_lib
+    FROM asset.copy
+    WHERE 
+            action.hold_request.shelf_time IS NOT NULL 
+        AND action.hold_request.capture_time IS NOT NULL
+        AND action.hold_request.current_copy IS NOT NULL
+        AND action.hold_request.fulfillment_time IS NULL
+        AND action.hold_request.cancel_time IS NULL
+        AND asset.copy.id = action.hold_request.current_copy
+        AND asset.copy.status = 8; -- on holds shelf
+
+COMMIT;
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.hold-current-shelf-lib.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.hold-current-shelf-lib.sql
deleted file mode 100644 (file)
index cec449c..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
--- Evergreen DB patch XXXX.schema.hold-current-shelf-lib.sql
---
--- FIXME: insert description of change, if needed
---
-BEGIN;
-
-
--- check whether patch can be applied
-SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
-
--- add the new column
-ALTER TABLE action.hold_request ADD COLUMN current_shelf_lib 
-    INT REFERENCES actor.org_unit DEFERRABLE INITIALLY DEFERRED;
-
--- set the value for current_shelf_lib on existing shelved holds
-UPDATE action.hold_request ahr
-    SET current_shelf_lib = pickup_lib
-    FROM asset.copy acp
-    WHERE 
-            ahr.shelf_time IS NOT NULL 
-        AND ahr.capture_time IS NOT NULL
-        AND ahr.current_copy IS NOT NULL
-        AND ahr.fulfillment_time IS NULL
-        AND ahr.cancel_time IS NULL
-        AND acp.id = ahr.current_copy
-        AND acp.status = 8; -- on holds shelf
-
-COMMIT;