]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/sql/Pg/upgrade/0822.schema.per-hold-behind-desk.sql
LP#1426133: Set merge_profile_id_seq explicitly
[working/Evergreen.git] / Open-ILS / src / sql / Pg / upgrade / 0822.schema.per-hold-behind-desk.sql
1 BEGIN;
2
3 SELECT evergreen.upgrade_deps_block_check('0822', :eg_version);
4
5 ALTER TABLE action.hold_request 
6     ADD COLUMN behind_desk BOOLEAN NOT NULL DEFAULT FALSE;
7
8 -- The value on the hold is the new arbiter of whether a 
9 -- hold should be held behind the desk and reported as such
10 -- Update existing holds that would in the current regime
11 -- be considered behind-the-desk holds to use the new column
12
13 UPDATE action.hold_request ahr
14     SET behind_desk = TRUE
15     FROM actor.usr_setting aus
16     WHERE 
17         ahr.cancel_time IS NULL AND
18         ahr.fulfillment_time IS NULL AND
19         aus.usr = ahr.usr AND
20         aus.name = 'circ.holds_behind_desk' AND
21         aus.value = 'true' AND
22         EXISTS (
23             SELECT 1 
24             FROM actor.org_unit_ancestor_setting(
25                 'circ.holds.behind_desk_pickup_supported', 
26                 ahr.pickup_lib
27             ) 
28             WHERE value = 'true'
29         );
30
31 COMMIT;