1 --Upgrade Script for 3.10.1 to 3.10.2
2 \set eg_version '''3.10.2'''
4 INSERT INTO config.upgrade_log (version, applied_to) VALUES ('3.10.2', :eg_version);
6 SELECT evergreen.upgrade_deps_block_check('1362', :eg_version);
8 CREATE INDEX hold_request_hopeless_date_idx ON action.hold_request (hopeless_date);
11 ANALYZE action.hold_request;
13 SELECT evergreen.upgrade_deps_block_check('1365', :eg_version);
15 CREATE OR REPLACE FUNCTION search.highlight_display_fields_impl(
18 field_list INT[] DEFAULT '{}'::INT[],
19 css_class TEXT DEFAULT 'oils_SH',
20 hl_all BOOL DEFAULT TRUE,
21 minwords INT DEFAULT 5,
22 maxwords INT DEFAULT 25,
23 shortwords INT DEFAULT 0,
24 maxfrags INT DEFAULT 0,
25 delimiter TEXT DEFAULT ' ... '
26 ) RETURNS SETOF search.highlight_result AS $f$
29 v_css_class TEXT := css_class;
30 v_delimiter TEXT := delimiter;
31 v_field_list INT[] := field_list;
34 IF v_delimiter LIKE $$%'%$$ OR v_delimiter LIKE '%"%' THEN --"
35 v_delimiter := ' ... ';
39 opts := opts || 'MinWords=' || minwords;
40 opts := opts || ', MaxWords=' || maxwords;
41 opts := opts || ', ShortWords=' || shortwords;
42 opts := opts || ', MaxFragments=' || maxfrags;
43 opts := opts || ', FragmentDelimiter="' || delimiter || '"';
45 opts := opts || 'HighlightAll=TRUE';
48 IF v_css_class LIKE $$%'%$$ OR v_css_class LIKE '%"%' THEN -- "
49 v_css_class := 'oils_SH';
52 opts := opts || $$, StopSel=</mark>, StartSel="<mark class='$$ || v_css_class; -- "
54 IF v_field_list = '{}'::INT[] THEN
55 SELECT ARRAY_AGG(id) INTO v_field_list FROM config.metabib_field WHERE display_field;
62 evergreen.escape_for_html(de.value) AS value,
65 evergreen.escape_for_html(de.value),
66 $$ || quote_literal(tsq) || $$,
67 $1 || ' ' || mf.field_class || ' ' || mf.name || $xx$'>"$xx$ -- "'
69 FROM metabib.display_entry de
70 JOIN config.metabib_field mf ON (mf.id = de.field)
71 JOIN search.best_tsconfig t ON (t.id = de.field)
76 RETURN QUERY EXECUTE hl_query USING opts, rid, v_field_list;
81 SELECT evergreen.upgrade_deps_block_check('1376', :eg_version);
85 CREATE OR REPLACE VIEW action.all_circulation_combined_types AS
86 SELECT acirc.id AS id,
91 ac_acirc.circ_modifier AS item_type,
92 'regular_circ'::text AS circ_type
93 FROM action.circulation acirc,
95 WHERE acirc.target_copy = ac_acirc.id
97 SELECT ancc.id::BIGINT AS id,
98 ancc.circ_time AS xact_start,
100 ancc.staff AS circ_staff,
101 ancc.circ_time AS create_time,
102 cnct_ancc.name AS item_type,
103 'non-cat_circ'::text AS circ_type
104 FROM action.non_cataloged_circulation ancc,
105 config.non_cataloged_type cnct_ancc
106 WHERE ancc.item_type = cnct_ancc.id
108 SELECT aihu.id::BIGINT AS id,
109 aihu.use_time AS xact_start,
110 aihu.org_unit AS circ_lib,
111 aihu.staff AS circ_staff,
112 aihu.use_time AS create_time,
113 ac_aihu.circ_modifier AS item_type,
114 'in-house_use'::text AS circ_type
115 FROM action.in_house_use aihu,
117 WHERE aihu.item = ac_aihu.id
119 SELECT ancihu.id::BIGINT AS id,
120 ancihu.use_time AS xact_start,
121 ancihu.org_unit AS circ_lib,
122 ancihu.staff AS circ_staff,
123 ancihu.use_time AS create_time,
124 cnct_ancihu.name AS item_type,
125 'non-cat-in-house_use'::text AS circ_type
126 FROM action.non_cat_in_house_use ancihu,
127 config.non_cataloged_type cnct_ancihu
128 WHERE ancihu.item_type = cnct_ancihu.id
130 SELECT aacirc.id AS id,
135 ac_aacirc.circ_modifier AS item_type,
136 'aged_circ'::text AS circ_type
137 FROM action.aged_circulation aacirc,
139 WHERE aacirc.target_copy = ac_aacirc.id;
143 INSERT INTO config.workstation_setting_type (name, grp, datatype, label)
145 'eg.staffcat.exclude_electronic', 'gui', 'bool',
147 'eg.staffcat.exclude_electronic',
148 'Staff Catalog "Exclude Electronic Resources" Option',
153 FROM config.workstation_setting_type
154 WHERE name = 'eg.staffcat.exclude_electronic'
159 INSERT INTO permission.perm_list ( id, code, description ) SELECT
160 625, 'VIEW_BOOKING_RESERVATION', oils_i18n_gettext(625,
161 'View booking reservations', 'ppl', 'description')
164 FROM permission.perm_list
166 AND code = 'VIEW_BOOKING_RESERVATION'
169 INSERT INTO permission.perm_list ( id, code, description ) SELECT
170 626, 'VIEW_BOOKING_RESERVATION_ATTR_MAP', oils_i18n_gettext(626,
171 'View booking reservation attribute maps', 'ppl', 'description')
174 FROM permission.perm_list
176 AND code = 'VIEW_BOOKING_RESERVATION_ATTR_MAP'
179 -- reprise 1269 just in case now that the perms should definitely exist
184 WHERE code IN ('VIEW_BOOKING_RESERVATION', 'VIEW_BOOKING_RESERVATION_ATTR_MAP'))
186 INSERT INTO permission.grp_perm_map (grp, perm, depth, grantable)
187 SELECT grp, perms_to_add.id as perm, depth, grantable
189 permission.grp_perm_map
191 --- Don't add the permissions if they have already been assigned
193 (SELECT DISTINCT grp FROM permission.grp_perm_map
194 INNER JOIN perms_to_add ON perm=perms_to_add.id)
196 --- Anybody who can view resources should also see reservations
197 --- at the same level
200 FROM permission.perm_list
201 WHERE code = 'VIEW_BOOKING_RESOURCE'
206 INSERT INTO config.workstation_setting_type (name, grp, datatype, label)
208 'eg.grid.booking.pull_list', 'gui', 'object',
211 'Grid Config: Booking Pull List',
215 FROM config.workstation_setting_type
216 WHERE name = 'eg.grid.booking.pull_list'
221 INSERT INTO action_trigger.event_params (event_def, param, value)
222 SELECT id, 'check_sms_notify', 1
223 FROM action_trigger.event_definition
224 WHERE reactor = 'SendSMS'
225 AND validator IN ('HoldIsAvailable', 'HoldIsCancelled', 'HoldNotifyCheck')
227 SELECT * FROM action_trigger.event_params
228 WHERE param = 'check_sms_notify'
231 -- fill in the gaps, but only if the upgrade log indicates that
232 -- this database had been at version 3.6.0 at some point.
233 INSERT INTO config.upgrade_log (version, applied_to) SELECT '1236', :eg_version
234 WHERE NOT EXISTS (SELECT 1 FROM config.upgrade_log WHERE version = '1236')
235 AND EXISTS (SELECT 1 FROM config.upgrade_log WHERE version = '3.6.0');
236 INSERT INTO config.upgrade_log (version, applied_to) SELECT '1237', :eg_version
237 WHERE NOT EXISTS (SELECT 1 FROM config.upgrade_log WHERE version = '1237')
238 AND EXISTS (SELECT 1 FROM config.upgrade_log WHERE version = '3.6.0');
239 INSERT INTO config.upgrade_log (version, applied_to) SELECT '1238', :eg_version
240 WHERE NOT EXISTS (SELECT 1 FROM config.upgrade_log WHERE version = '1238')
241 AND EXISTS (SELECT 1 FROM config.upgrade_log WHERE version = '3.6.0');
242 INSERT INTO config.upgrade_log (version, applied_to) SELECT '1239', :eg_version
243 WHERE NOT EXISTS (SELECT 1 FROM config.upgrade_log WHERE version = '1239')
244 AND EXISTS (SELECT 1 FROM config.upgrade_log WHERE version = '3.6.0');
245 INSERT INTO config.upgrade_log (version, applied_to) SELECT '1240', :eg_version
246 WHERE NOT EXISTS (SELECT 1 FROM config.upgrade_log WHERE version = '1240')
247 AND EXISTS (SELECT 1 FROM config.upgrade_log WHERE version = '3.6.0');
250 -- check whether patch can be applied
251 SELECT evergreen.upgrade_deps_block_check('1377', :eg_version);
253 -- 950.data.seed-values.sql
255 INSERT INTO config.global_flag (name, value, enabled, label)
257 'opac.login_redirect_domains',
261 'opac.login_redirect_domains',
262 'Restrict post-login redirection to local URLs, or those that match the supplied comma-separated list of foreign domains or host names.',
269 SELECT evergreen.upgrade_deps_block_check('1378', :eg_version);
271 CREATE OR REPLACE FUNCTION search.highlight_display_fields(
273 tsq_map TEXT, -- '(a | b) & c' => '1,2,3,4', ...
274 css_class TEXT DEFAULT 'oils_SH',
275 hl_all BOOL DEFAULT TRUE,
276 minwords INT DEFAULT 5,
277 maxwords INT DEFAULT 25,
278 shortwords INT DEFAULT 0,
279 maxfrags INT DEFAULT 0,
280 delimiter TEXT DEFAULT ' ... '
281 ) RETURNS SETOF search.highlight_result AS $f$
289 FOR tsq, fields IN SELECT key, value FROM each(tsq_map::HSTORE) LOOP
290 SELECT ARRAY_AGG(unnest::INT) INTO afields
291 FROM unnest(regexp_split_to_array(fields,','));
292 seen := seen || afields;
295 SELECT * FROM search.highlight_display_fields_impl(
296 rid, tsq, afields, css_class, hl_all,minwords,
297 maxwords, shortwords, maxfrags, delimiter
305 evergreen.escape_for_html(value) AS value,
306 evergreen.escape_for_html(value) AS highlight
307 FROM metabib.display_entry
309 AND NOT (field = ANY (seen));
311 $f$ LANGUAGE PLPGSQL ROWS 10;
316 -- Update auditor tables to catch changes to source tables.
317 -- Can be removed/skipped if there were no schema changes.
318 SELECT auditor.update_auditors();