]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/sql/Pg/version-upgrade/3.4.1-3.4.2-upgrade-db.sql
Forward Port 3.4.1 to 3.4.2 upgrade script
[Evergreen.git] / Open-ILS / src / sql / Pg / version-upgrade / 3.4.1-3.4.2-upgrade-db.sql
1 --Upgrade Script for 3.4.1 to 3.4.2
2 \set eg_version '''3.4.2'''
3 BEGIN;
4 INSERT INTO config.upgrade_log (version, applied_to) VALUES ('3.4.2', :eg_version);
5
6 SELECT evergreen.upgrade_deps_block_check('1197', :eg_version);
7
8 INSERT INTO config.workstation_setting_type (name, grp, datatype, label)
9 VALUES (
10     'eg.hatch.enable.printing', 'gui', 'bool',
11     oils_i18n_gettext(
12         'eg.hatch.enable.printing',
13         'Use Hatch for printing',
14         'cwst', 'label'
15     )
16 );
17
18
19 DO $SQL$
20 BEGIN
21
22     PERFORM COUNT(*), workstation, name 
23     FROM actor.workstation_setting GROUP BY 2, 3 HAVING COUNT(*) > 1;
24
25     IF FOUND THEN
26
27         RAISE NOTICE $NOTICE$
28
29 ---
30 The actor.workstation_setting table contains duplicate rows.  The duplicates 
31 should be removed before applying a new UNIQUE constraint.  To find the rows, 
32 execute the following SQL:
33
34 SELECT COUNT(*), workstation, name FROM actor.workstation_setting 
35     GROUP BY 2, 3 HAVING COUNT(*) > 1;  
36     
37 Once the duplicates are cleared, execute the following SQL: 
38
39 ALTER TABLE actor.workstation_setting 
40     ADD CONSTRAINT ws_once_per_key UNIQUE (workstation, name);
41 ---
42
43 $NOTICE$;
44
45     ELSE
46
47         ALTER TABLE actor.workstation_setting
48             ADD CONSTRAINT ws_once_per_key UNIQUE (workstation, name);
49     END IF;
50
51 END;
52 $SQL$;
53
54
55
56 COMMIT;
57
58 -- Update auditor tables to catch changes to source tables.
59 --   Can be removed/skipped if there were no schema changes.
60 SELECT auditor.update_auditors();