]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/sql/Pg/1.2.2.2-1.2.2.3-upgrade-db.sql
removing overly agressive locale normalization
[Evergreen.git] / Open-ILS / src / sql / Pg / 1.2.2.2-1.2.2.3-upgrade-db.sql
1 /*
2  * Copyright (C) 2008  Equinox Software, Inc.
3  * Mike Rylander <miker@esilibrary.com.com>
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  */
16
17
18 -- It's OK if any of the following, before the transaction, fails ...
19
20 CREATE SCHEMA extend_reporter;
21
22 CREATE TABLE extend_reporter.legacy_circ_count (
23     id          BIGSERIAL   PRIMARY KEY REFERENCES asset.copy (id),
24     circ_count  INT         NOT NULL DEFAULT 0
25 );
26
27 INSERT INTO permission.perm_list (code, description) VALUES ('DELETE_RECORD', 'Allow a staff member to directly remove a bibliographic record');
28 SELECT SETVAL('permission.perm_list_id_seq'::TEXT, (SELECT MAX(id) FROM permission.perm_list));
29
30 BEGIN;
31
32 CREATE OR REPLACE VIEW extend_reporter.full_circ_count AS
33  SELECT cp.id, COALESCE(sum(c.circ_count), 0::bigint) + COALESCE(count(circ.id), 0::bigint) AS circ_count
34    FROM asset."copy" cp
35    LEFT JOIN extend_reporter.legacy_circ_count c USING (id)
36    LEFT JOIN "action".circulation circ ON circ.target_copy = c.id
37   GROUP BY cp.id;
38
39 UPDATE  metabib.title_field_entry
40   SET   value = REGEXP_REPLACE(value, E'(\\d{4})-(\\d{4})', E'\\1 \\2','g')
41   WHERE value ~ E'(\\d{4})-(\\d{4})';
42
43 UPDATE  metabib.author_field_entry
44   SET   value = REGEXP_REPLACE(value, E'(\\d{4})-(\\d{4})', E'\\1 \\2','g')
45   WHERE value ~ E'(\\d{4})-(\\d{4})';
46
47 UPDATE  metabib.keyword_field_entry
48   SET   value = REGEXP_REPLACE(value, E'(\\d{4})-(\\d{4})', E'\\1 \\2','g')
49   WHERE value ~ E'(\\d{4})-(\\d{4})';
50
51 UPDATE  metabib.subject_field_entry
52   SET   value = REGEXP_REPLACE(value, E'(\\d{4})-(\\d{4})', E'\\1 \\2','g')
53   WHERE value ~ E'(\\d{4})-(\\d{4})';
54
55 UPDATE  metabib.series_field_entry
56   SET   value = REGEXP_REPLACE(value, E'(\\d{4})-(\\d{4})', E'\\1 \\2','g')
57   WHERE value ~ E'(\\d{4})-(\\d{4})';
58
59 UPDATE  metabib.full_rec
60   SET   value = REGEXP_REPLACE(value, E'(\\d{4})-(\\d{4})', E'\\1 \\2','g')
61   WHERE value ~ E'(\\d{4})-(\\d{4})';
62
63 COMMIT;
64