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,
--- /dev/null
+-- 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;
+++ /dev/null
--- 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;