]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/sql/Pg/upgrade/1376.schema.catch-up-on-missing-dbrevs-from-3-6-0.sql
LP#1920826: Add release notes and stamp upgrade script
[Evergreen.git] / Open-ILS / src / sql / Pg / upgrade / 1376.schema.catch-up-on-missing-dbrevs-from-3-6-0.sql
1 BEGIN;
2
3 SELECT evergreen.upgrade_deps_block_check('1376', :eg_version);
4
5 -- 1236
6
7 CREATE OR REPLACE VIEW action.all_circulation_combined_types AS
8  SELECT acirc.id AS id,
9     acirc.xact_start,
10     acirc.circ_lib,
11     acirc.circ_staff,
12     acirc.create_time,
13     ac_acirc.circ_modifier AS item_type,
14     'regular_circ'::text AS circ_type
15    FROM action.circulation acirc,
16     asset.copy ac_acirc
17   WHERE acirc.target_copy = ac_acirc.id
18 UNION ALL
19  SELECT ancc.id::BIGINT AS id,
20     ancc.circ_time AS xact_start,
21     ancc.circ_lib,
22     ancc.staff AS circ_staff,
23     ancc.circ_time AS create_time,
24     cnct_ancc.name AS item_type,
25     'non-cat_circ'::text AS circ_type
26    FROM action.non_cataloged_circulation ancc,
27     config.non_cataloged_type cnct_ancc
28   WHERE ancc.item_type = cnct_ancc.id
29 UNION ALL
30  SELECT aihu.id::BIGINT AS id,
31     aihu.use_time AS xact_start,
32     aihu.org_unit AS circ_lib,
33     aihu.staff AS circ_staff,
34     aihu.use_time AS create_time,
35     ac_aihu.circ_modifier AS item_type,
36     'in-house_use'::text AS circ_type
37    FROM action.in_house_use aihu,
38     asset.copy ac_aihu
39   WHERE aihu.item = ac_aihu.id
40 UNION ALL
41  SELECT ancihu.id::BIGINT AS id,
42     ancihu.use_time AS xact_start,
43     ancihu.org_unit AS circ_lib,
44     ancihu.staff AS circ_staff,
45     ancihu.use_time AS create_time,
46     cnct_ancihu.name AS item_type,
47     'non-cat-in-house_use'::text AS circ_type
48    FROM action.non_cat_in_house_use ancihu,
49     config.non_cataloged_type cnct_ancihu
50   WHERE ancihu.item_type = cnct_ancihu.id
51 UNION ALL
52  SELECT aacirc.id AS id,
53     aacirc.xact_start,
54     aacirc.circ_lib,
55     aacirc.circ_staff,
56     aacirc.create_time,
57     ac_aacirc.circ_modifier AS item_type,
58     'aged_circ'::text AS circ_type
59    FROM action.aged_circulation aacirc,
60     asset.copy ac_aacirc
61   WHERE aacirc.target_copy = ac_aacirc.id;
62
63 -- 1237
64
65 INSERT INTO config.workstation_setting_type (name, grp, datatype, label)
66 SELECT
67     'eg.staffcat.exclude_electronic', 'gui', 'bool',
68     oils_i18n_gettext(
69         'eg.staffcat.exclude_electronic',
70         'Staff Catalog "Exclude Electronic Resources" Option',
71         'cwst', 'label'
72     )
73 WHERE NOT EXISTS (
74     SELECT 1
75     FROM config.workstation_setting_type
76     WHERE name = 'eg.staffcat.exclude_electronic'
77 );
78
79 -- 1238
80
81 INSERT INTO permission.perm_list ( id, code, description ) SELECT
82  625, 'VIEW_BOOKING_RESERVATION', oils_i18n_gettext(625,
83     'View booking reservations', 'ppl', 'description')
84 WHERE NOT EXISTS (
85     SELECT 1
86     FROM permission.perm_list
87     WHERE id = 625
88     AND   code = 'VIEW_BOOKING_RESERVATION'
89 );
90
91 INSERT INTO permission.perm_list ( id, code, description ) SELECT
92  626, 'VIEW_BOOKING_RESERVATION_ATTR_MAP', oils_i18n_gettext(626,
93     'View booking reservation attribute maps', 'ppl', 'description')
94 WHERE NOT EXISTS (
95     SELECT 1
96     FROM permission.perm_list
97     WHERE id = 626
98     AND   code = 'VIEW_BOOKING_RESERVATION_ATTR_MAP'
99 );
100
101 -- reprise 1269 just in case now that the perms should definitely exist
102
103 WITH perms_to_add AS
104     (SELECT id FROM
105     permission.perm_list
106     WHERE code IN ('VIEW_BOOKING_RESERVATION', 'VIEW_BOOKING_RESERVATION_ATTR_MAP'))
107
108 INSERT INTO permission.grp_perm_map (grp, perm, depth, grantable)
109     SELECT grp, perms_to_add.id as perm, depth, grantable
110         FROM perms_to_add,
111         permission.grp_perm_map
112         
113         --- Don't add the permissions if they have already been assigned
114         WHERE grp NOT IN
115             (SELECT DISTINCT grp FROM permission.grp_perm_map
116             INNER JOIN perms_to_add ON perm=perms_to_add.id)
117             
118         --- Anybody who can view resources should also see reservations
119         --- at the same level
120         AND perm = (
121             SELECT id
122                 FROM permission.perm_list
123                 WHERE code = 'VIEW_BOOKING_RESOURCE'
124         );
125
126 -- 1239
127
128 INSERT INTO config.workstation_setting_type (name, grp, datatype, label)
129 SELECT
130     'eg.grid.booking.pull_list', 'gui', 'object',
131     oils_i18n_gettext(
132         'booking.pull_list',
133         'Grid Config: Booking Pull List',
134         'cwst', 'label')
135 WHERE NOT EXISTS (
136     SELECT 1
137     FROM config.workstation_setting_type
138     WHERE name = 'eg.grid.booking.pull_list'
139 );
140
141 -- 1240
142
143 INSERT INTO action_trigger.event_params (event_def, param, value)
144 SELECT id, 'check_sms_notify', 1
145 FROM action_trigger.event_definition
146 WHERE reactor = 'SendSMS'
147 AND validator IN ('HoldIsAvailable', 'HoldIsCancelled', 'HoldNotifyCheck')
148 AND NOT EXISTS (
149     SELECT * FROM action_trigger.event_params
150     WHERE param = 'check_sms_notify'
151 );
152
153 -- fill in the gaps, but only if the upgrade log indicates that
154 -- this database had been at version 3.6.0 at some point.
155 INSERT INTO config.upgrade_log (version, applied_to) SELECT '1236', :eg_version
156 WHERE NOT EXISTS (SELECT 1 FROM config.upgrade_log WHERE version = '1236')
157 AND       EXISTS (SELECT 1 FROM config.upgrade_log WHERE version = '3.6.0');
158 INSERT INTO config.upgrade_log (version, applied_to) SELECT '1237', :eg_version
159 WHERE NOT EXISTS (SELECT 1 FROM config.upgrade_log WHERE version = '1237')
160 AND       EXISTS (SELECT 1 FROM config.upgrade_log WHERE version = '3.6.0');
161 INSERT INTO config.upgrade_log (version, applied_to) SELECT '1238', :eg_version
162 WHERE NOT EXISTS (SELECT 1 FROM config.upgrade_log WHERE version = '1238')
163 AND       EXISTS (SELECT 1 FROM config.upgrade_log WHERE version = '3.6.0');
164 INSERT INTO config.upgrade_log (version, applied_to) SELECT '1239', :eg_version
165 WHERE NOT EXISTS (SELECT 1 FROM config.upgrade_log WHERE version = '1239')
166 AND       EXISTS (SELECT 1 FROM config.upgrade_log WHERE version = '3.6.0');
167 INSERT INTO config.upgrade_log (version, applied_to) SELECT '1240', :eg_version
168 WHERE NOT EXISTS (SELECT 1 FROM config.upgrade_log WHERE version = '1240')
169 AND       EXISTS (SELECT 1 FROM config.upgrade_log WHERE version = '3.6.0');
170
171 COMMIT;