]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/sql/Pg/upgrade/0986.schema.patron_unaccent.sql
LP#1744385: Additions and edits to release note entry
[working/Evergreen.git] / Open-ILS / src / sql / Pg / upgrade / 0986.schema.patron_unaccent.sql
1 BEGIN;
2
3 SELECT evergreen.upgrade_deps_block_check('0986', :eg_version);
4
5 CREATE EXTENSION IF NOT EXISTS unaccent SCHEMA public;
6
7 CREATE OR REPLACE FUNCTION evergreen.unaccent_and_squash ( IN arg text) RETURNS text
8     IMMUTABLE STRICT AS $$
9         BEGIN
10         RETURN evergreen.lowercase(unaccent(regexp_replace(arg, '\s','','g')));
11         END;
12 $$ LANGUAGE PLPGSQL;
13
14 -- The unaccented indices for patron name fields
15 CREATE INDEX actor_usr_first_given_name_unaccent_idx ON actor.usr (evergreen.unaccent_and_squash(first_given_name));
16 CREATE INDEX actor_usr_second_given_name_unaccent_idx ON actor.usr (evergreen.unaccent_and_squash(second_given_name));
17 CREATE INDEX actor_usr_family_name_unaccent_idx ON actor.usr (evergreen.unaccent_and_squash(family_name));
18
19 -- DB setting to control behavior; true by default
20 INSERT INTO config.org_unit_setting_type
21 ( name, grp, label, description, datatype )
22 VALUES
23 ('circ.patron_search.diacritic_insensitive',
24  'circ',
25  oils_i18n_gettext('circ.patron_search.diacritic_insensitive',
26      'Patron search diacritic insensitive',
27      'coust', 'label'),
28  oils_i18n_gettext('circ.patron_search.diacritic_insensitive',
29      'Match patron last, first, and middle names irrespective of usage of diacritical marks or spaces. (e.g., Ines will match InĂ©s; de la Cruz will match Delacruz)',
30      'coust', 'description'),
31   'bool');
32
33 INSERT INTO actor.org_unit_setting (
34     org_unit, name, value
35 ) VALUES (
36     (SELECT id FROM actor.org_unit WHERE parent_ou IS NULL),
37     'circ.patron_search.diacritic_insensitive',
38     'true'
39 );
40
41
42 COMMIT;
43