]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/sql/Pg/1.2.2.1-1.2.2.2-upgrade-db.sql
Qstore: support LIMIT and OFFSET clauses.
[working/Evergreen.git] / Open-ILS / src / sql / Pg / 1.2.2.1-1.2.2.2-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 BEGIN;
18
19 CREATE SCHEMA extend_reporter;
20
21 CREATE TABLE extend_reporter.legacy_circ_count (
22     id          BIGSERIAL   PRIMARY KEY REFERENCES asset.copy (id) DEFERRABLE INITIALLY DEFERRED,
23     circ_count  INT         NOT NULL DEFAULT 0
24 );
25
26 CREATE VIEW extend_reporter.full_circ_count AS
27  SELECT cp.id, COALESCE(sum(c.circ_count), 0::bigint) + COALESCE(count(circ.id), 0::bigint) AS circ_count
28    FROM asset."copy" cp
29    LEFT JOIN extend_reporter.legacy_circ_count c USING (id)
30    LEFT JOIN "action".circulation circ ON circ.target_copy = c.id
31   GROUP BY cp.id;
32
33 UPDATE  metabib.title_field_entry
34   SET   value = REGEXP_REPLACE(value, E'(\\d{4})-(\\d{4})', E'\\1 \\2','g')
35   WHERE value ~ E'(\\d{4})-(\\d{4})';
36
37 UPDATE  metabib.author_field_entry
38   SET   value = REGEXP_REPLACE(value, E'(\\d{4})-(\\d{4})', E'\\1 \\2','g')
39   WHERE value ~ E'(\\d{4})-(\\d{4})';
40
41 UPDATE  metabib.keyword_field_entry
42   SET   value = REGEXP_REPLACE(value, E'(\\d{4})-(\\d{4})', E'\\1 \\2','g')
43   WHERE value ~ E'(\\d{4})-(\\d{4})';
44
45 UPDATE  metabib.subject_field_entry
46   SET   value = REGEXP_REPLACE(value, E'(\\d{4})-(\\d{4})', E'\\1 \\2','g')
47   WHERE value ~ E'(\\d{4})-(\\d{4})';
48
49 UPDATE  metabib.series_field_entry
50   SET   value = REGEXP_REPLACE(value, E'(\\d{4})-(\\d{4})', E'\\1 \\2','g')
51   WHERE value ~ E'(\\d{4})-(\\d{4})';
52
53 UPDATE  metabib.full_rec
54   SET   value = REGEXP_REPLACE(value, E'(\\d{4})-(\\d{4})', E'\\1 \\2','g')
55   WHERE value ~ E'(\\d{4})-(\\d{4})';
56
57 COMMIT;
58