]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/sql/Pg/upgrade/0760.schema.custom-best-hold-selection.sql
LP2042879 Shelving Location Groups Admin accessibility
[Evergreen.git] / Open-ILS / src / sql / Pg / upgrade / 0760.schema.custom-best-hold-selection.sql
1 BEGIN;
2
3 SELECT evergreen.upgrade_deps_block_check('0760', :eg_version);
4
5 CREATE TABLE config.best_hold_order(
6     id          SERIAL      PRIMARY KEY,    -- (metadata)
7     name        TEXT        UNIQUE,   -- i18n (metadata)
8     pprox       INT, -- copy capture <-> pickup lib prox
9     hprox       INT, -- copy circ lib <-> request lib prox
10     aprox       INT, -- copy circ lib <-> pickup lib ADJUSTED prox on ahcm
11     approx      INT, -- copy capture <-> pickup lib ADJUSTED prox from function
12     priority    INT, -- group hold priority
13     cut         INT, -- cut-in-line
14     depth       INT, -- selection depth
15     htime       INT, -- time since last home-lib circ exceeds org-unit setting
16     rtime       INT, -- request time
17     shtime      INT  -- time since copy last trip home exceeds org-unit setting
18 );
19
20 -- At least one of these columns must contain a non-null value
21 ALTER TABLE config.best_hold_order ADD CHECK ((
22     pprox IS NOT NULL OR
23     hprox IS NOT NULL OR
24     aprox IS NOT NULL OR
25     priority IS NOT NULL OR
26     cut IS NOT NULL OR
27     depth IS NOT NULL OR
28     htime IS NOT NULL OR
29     rtime IS NOT NULL
30 ));
31
32 INSERT INTO config.best_hold_order (
33     name,
34     pprox, aprox, priority, cut, depth, rtime, htime, hprox
35 ) VALUES (
36     'Traditional',
37     1, 2, 3, 4, 5, 6, 7, 8
38 );
39
40 INSERT INTO config.best_hold_order (
41     name,
42     hprox, pprox, aprox, priority, cut, depth, rtime, htime
43 ) VALUES (
44     'Traditional with Holds-always-go-home',
45     1, 2, 3, 4, 5, 6, 7, 8
46 );
47
48 INSERT INTO config.best_hold_order (
49     name,
50     htime, hprox, pprox, aprox, priority, cut, depth, rtime
51 ) VALUES (
52     'Traditional with Holds-go-home',
53     1, 2, 3, 4, 5, 6, 7, 8
54 );
55
56 INSERT INTO config.best_hold_order (
57     name,
58     priority, cut, rtime, depth, pprox, hprox, aprox, htime
59 ) VALUES (
60     'FIFO',
61     1, 2, 3, 4, 5, 6, 7, 8
62 );
63
64 INSERT INTO config.best_hold_order (
65     name,
66     hprox, priority, cut, rtime, depth, pprox, aprox, htime
67 ) VALUES (
68     'FIFO with Holds-always-go-home',
69     1, 2, 3, 4, 5, 6, 7, 8
70 );
71
72 INSERT INTO config.best_hold_order (
73     name,
74     htime, priority, cut, rtime, depth, pprox, aprox, hprox
75 ) VALUES (
76     'FIFO with Holds-go-home',
77     1, 2, 3, 4, 5, 6, 7, 8
78 );
79
80 INSERT INTO permission.perm_list (
81     id, code, description
82 ) VALUES (
83     546,
84     'ADMIN_HOLD_CAPTURE_SORT',
85     oils_i18n_gettext(
86         546,
87         'Allows a user to make changes to best-hold selection sort order',
88         'ppl',
89         'description'
90     )
91 );
92
93 INSERT INTO config.org_unit_setting_type (
94     name, label, description, datatype, fm_class, update_perm, grp
95 ) VALUES (
96     'circ.hold_capture_order',
97     oils_i18n_gettext(
98         'circ.hold_capture_order',
99         'Best-hold selection sort order',
100         'coust',
101         'label'
102     ),
103     oils_i18n_gettext(
104         'circ.hold_capture_order',
105         'Defines the sort order of holds when selecting a hold to fill using a given copy at capture time',
106         'coust',
107         'description'
108     ),
109     'link',
110     'cbho',
111     546,
112     'holds'
113 );
114
115 INSERT INTO config.org_unit_setting_type (
116     name, label, description, datatype, update_perm, grp
117 ) VALUES (
118     'circ.hold_go_home_interval',
119     oils_i18n_gettext(
120         'circ.hold_go_home_interval',
121         'Max foreign-circulation time',
122         'coust',
123         'label'
124     ),
125     oils_i18n_gettext(
126         'circ.hold_go_home_interval',
127         'Time a copy can spend circulating away from its circ lib before returning there to fill a hold (if one exists there)',
128         'coust',
129         'description'
130     ),
131     'interval',
132     546,
133     'holds'
134 );
135
136 INSERT INTO actor.org_unit_setting (
137     org_unit, name, value
138 ) VALUES (
139     (SELECT id FROM actor.org_unit WHERE parent_ou IS NULL),
140     'circ.hold_go_home_interval',
141     '"6 months"'
142 );
143
144 UPDATE actor.org_unit_setting SET
145     name = 'circ.hold_capture_order',
146     value = (SELECT id FROM config.best_hold_order WHERE name = 'FIFO')
147 WHERE
148     name = 'circ.holds_fifo' AND value ILIKE '%true%';
149
150 COMMIT;