]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/sql/Pg/upgrade/0323.data.booking.elbow_room.sql
LP#1744385: Additions and edits to release note entry
[working/Evergreen.git] / Open-ILS / src / sql / Pg / upgrade / 0323.data.booking.elbow_room.sql
1 -- This statement ok to fail if the row is already there in coust. You will
2 -- already have this if you have a
3 -- very old trunk installation (because this has been added by an earlier
4 -- upgrade script (0109), but has not been in the default seed data until
5 -- recently
6 INSERT INTO config.org_unit_setting_type
7     (name, label, description, datatype) VALUES (
8         'circ.booking_reservation.default_elbow_room',
9         oils_i18n_gettext(
10             'circ.booking_reservation.default_elbow_room',
11             'Booking: Elbow room',
12             'coust',
13             'label'
14         ),
15         oils_i18n_gettext(
16             'circ.booking_reservation.default_elbow_room',
17             'Elbow room specifies how far in the future you must make a reservation on an item if that item will have to transit to reach its pickup location.  It secondarily defines how soon a reservation on a given item must start before the check-in process will opportunistically capture it for the reservation shelf.',
18             'coust',
19             'label'
20         ),
21         'interval'
22     );
23
24 BEGIN;
25
26 INSERT INTO config.upgrade_log (version) VALUES ('0323'); -- senator
27
28 -- In booking, elbow room defines:
29 --  a) how far in the future you must make a reservation on a given item if
30 --      that item will have to transit somewhere to fulfill the reservation.
31 --  b) how soon a reservation must be starting for the reserved item to
32 --      be op-captured by the checkin interface.
33
34 -- We don't want to clobber any default_elbow room at any level:
35
36 CREATE OR REPLACE FUNCTION pg_temp.default_elbow() RETURNS INTEGER AS $$
37 DECLARE
38     existing    actor.org_unit_setting%ROWTYPE;
39 BEGIN
40     SELECT INTO existing id FROM actor.org_unit_setting WHERE name = 'circ.booking_reservation.default_elbow_room';
41     IF NOT FOUND THEN
42         INSERT INTO actor.org_unit_setting (org_unit, name, value) VALUES (
43             (SELECT id FROM actor.org_unit WHERE parent_ou IS NULL),
44             'circ.booking_reservation.default_elbow_room',
45             '"1 day"'
46         );
47         RETURN 1;
48     END IF;
49     RETURN 0;
50 END;
51 $$ LANGUAGE plpgsql;
52
53 SELECT pg_temp.default_elbow();
54
55 COMMIT;