]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/sql/Pg/version-upgrade/2.12.0-2.12.1-upgrade-db.sql
LP#1772028 Add some FK violation functions just in case they are missing
[Evergreen.git] / Open-ILS / src / sql / Pg / version-upgrade / 2.12.0-2.12.1-upgrade-db.sql
1 --Upgrade Script for 2.12.0 to 2.12.1
2 \set eg_version '''2.12.1'''
3 BEGIN;
4 INSERT INTO config.upgrade_log (version, applied_to) VALUES ('2.12.1', :eg_version);
5
6 SELECT evergreen.upgrade_deps_block_check('1033', :eg_version);
7
8 -- correctly turn off browsing for subjectd|geograhic and
9 -- subject|temporal now that the *_browse versions exist. This is
10 -- a no-op in a database that was started at version 2.12.0.
11 UPDATE config.metabib_field
12 SET browse_field = FALSE
13 WHERE field_class = 'subject' AND name = 'geographic'
14 AND browse_field
15 AND id = 11;
16 UPDATE config.metabib_field
17 SET browse_field = FALSE
18 WHERE field_class = 'subject' AND name = 'temporal'
19 AND browse_field
20 AND id = 13;
21
22 select b.tag, idx.name
23 from authority.control_set_bib_field b
24 join authority.control_set_bib_field_metabib_field_map map on (b.id = map.bib_field)
25 join config.metabib_field idx on (map.metabib_field = idx.id)
26 order by b.tag;
27
28 -- and fix bib field mapping if necessasry
29 UPDATE authority.control_set_bib_field_metabib_field_map map
30 SET metabib_field = cmf.id
31 FROM config.metabib_field cmf
32 WHERE cmf.field_class = 'subject' AND cmf.name= 'temporal_browse'
33 AND   map.bib_field IN (
34     SELECT b.id
35     FROM authority.control_set_bib_field b
36     JOIN authority.control_set_authority_field a
37     ON (b.authority_field = a.id)
38     AND a.tag = '148'
39 )
40 AND   map.metabib_field IN (
41     SELECT id
42     FROM config.metabib_field
43     WHERE field_class = 'subject' AND name = 'geographic_browse'
44 );
45 UPDATE authority.control_set_bib_field_metabib_field_map map
46 SET metabib_field = cmf.id
47 FROM config.metabib_field cmf
48 WHERE cmf.field_class = 'subject' AND cmf.name= 'geographic_browse'
49 AND   map.bib_field IN (
50     SELECT b.id
51     FROM authority.control_set_bib_field b
52     JOIN authority.control_set_authority_field a
53     ON (b.authority_field = a.id)
54     AND a.tag = '151'
55 )
56 AND   map.metabib_field IN (
57     SELECT id
58     FROM config.metabib_field
59     WHERE field_class = 'subject' AND name = 'temporal_browse'
60 );
61 COMMIT;
62
63 \qecho Verify that bib subject fields appear to be mapped to
64 \qecho to correct browse indexes
65 SELECT b.id, b.tag, idx.field_class, idx.name
66 FROM authority.control_set_bib_field b
67 JOIN authority.control_set_bib_field_metabib_field_map map ON (b.id = map.bib_field)
68 JOIN config.metabib_field idx ON (map.metabib_field = idx.id)
69 WHERE tag ~ '^6'
70 ORDER BY b.tag;
71
72
73 \qecho This is a browse-only reingest of your bib records. It may take a while.
74 \qecho You may cancel now without losing the effect of the rest of the
75 \qecho upgrade script, and arrange the reingest later.
76 \qecho .
77 SELECT metabib.reingest_metabib_field_entries(id, TRUE, FALSE, TRUE)
78     FROM biblio.record_entry;