From: Bill Erickson Date: Tue, 27 Dec 2011 17:19:05 +0000 (-0500) Subject: Hold current_shelf_lib DB and IDL X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=a9e670511c2953bcd16fce74a48cd8b7a7cb43e0;p=evergreen%2Fmasslnc.git Hold current_shelf_lib DB and IDL Schema, upgrade, and IDL pieces for a new action.hold_request.current_shelf_lib column. The goal of the column is to track the location where a hold is currently sitting on a hold shelf. Typically, this will be the pickup library, however, if the pickup library has changed while the hold was on the shelf, the current shelf lib will be different. The upgrade script sets current_shelf_lib to match the pickup_lib for all holds that are currently active and on the shelf. Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index 7e0b301081..42807fd398 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -4520,6 +4520,7 @@ SELECT usr, + @@ -4536,6 +4537,7 @@ SELECT usr, + @@ -4580,6 +4582,7 @@ SELECT usr, + @@ -4596,6 +4599,7 @@ SELECT usr, + diff --git a/Open-ILS/src/sql/Pg/090.schema.action.sql b/Open-ILS/src/sql/Pg/090.schema.action.sql index 05c45add4d..111b53da02 100644 --- a/Open-ILS/src/sql/Pg/090.schema.action.sql +++ b/Open-ILS/src/sql/Pg/090.schema.action.sql @@ -357,7 +357,8 @@ CREATE TABLE action.hold_request ( shelf_time TIMESTAMP WITH TIME ZONE, cut_in_line BOOL, mint_condition BOOL NOT NULL DEFAULT TRUE, - shelf_expire_time TIMESTAMPTZ + shelf_expire_time TIMESTAMPTZ, + current_shelf_lib INT REFERENCES actor.org_unit DEFERRABLE INITIALLY DEFERRED ); CREATE INDEX hold_request_target_idx ON action.hold_request (target); 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 new file mode 100644 index 0000000000..cec449c7ca --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.hold-current-shelf-lib.sql @@ -0,0 +1,28 @@ +-- 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;