]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/sql/Pg/upgrade/1197.data.hatch-enable-print.sql
LP1830391 Stamping DB upgrate (hatch omnibus)
[working/Evergreen.git] / Open-ILS / src / sql / Pg / upgrade / 1197.data.hatch-enable-print.sql
1 BEGIN;
2
3 SELECT evergreen.upgrade_deps_block_check('1197', :eg_version);
4
5 INSERT INTO config.workstation_setting_type (name, grp, datatype, label)
6 VALUES (
7     'eg.hatch.enable.printing', 'gui', 'bool',
8     oils_i18n_gettext(
9         'eg.hatch.enable.printing',
10         'Use Hatch for printing',
11         'cwst', 'label'
12     )
13 );
14
15
16 DO $SQL$
17 BEGIN
18
19     PERFORM COUNT(*), workstation, name 
20     FROM actor.workstation_setting GROUP BY 2, 3 HAVING COUNT(*) > 1;
21
22     IF FOUND THEN
23
24         RAISE NOTICE $NOTICE$
25
26 ---
27 The actor.workstation_setting table contains duplicate rows.  The duplicates 
28 should be removed before applying a new UNIQUE constraint.  To find the rows, 
29 execute the following SQL:
30
31 SELECT COUNT(*), workstation, name FROM actor.workstation_setting 
32     GROUP BY 2, 3 HAVING COUNT(*) > 1;  
33     
34 Once the duplicates are cleared, execute the following SQL: 
35
36 ALTER TABLE actor.workstation_setting 
37     ADD CONSTRAINT ws_once_per_key UNIQUE (workstation, name);
38 ---
39
40 $NOTICE$;
41
42     ELSE
43
44         ALTER TABLE actor.workstation_setting
45             ADD CONSTRAINT ws_once_per_key UNIQUE (workstation, name);
46     END IF;
47
48 END;
49 $SQL$;
50
51 COMMIT;
52
53