From: Mike Rylander Date: Mon, 9 Jan 2012 18:49:40 +0000 (-0500) Subject: Stamping upgrade script for current_shelf_lib X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=663317194fcf77ef584634adc543d050457821ac;p=evergreen%2Fmasslnc.git Stamping upgrade script for current_shelf_lib Signed-off-by: Mike Rylander --- diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index c08457d09f..87e71502db 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -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 index 0000000000..f46db9301c --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/0664.schema.hold-current-shelf-lib.sql @@ -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 index cec449c7ca..0000000000 --- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.hold-current-shelf-lib.sql +++ /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;