Stamped upgrade for full circ count view fix
authorMike Rylander <mrylander@gmail.com>
Tue, 15 Nov 2011 21:25:53 +0000 (16:25 -0500)
committerMike Rylander <mrylander@gmail.com>
Tue, 15 Nov 2011 21:25:53 +0000 (16:25 -0500)
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/src/sql/Pg/002.schema.config.sql
Open-ILS/src/sql/Pg/upgrade/0649.schema.fix_full_circ_count_view.sql [new file with mode: 0644]
Open-ILS/src/sql/Pg/upgrade/XXXX.schema.fix_full_circ_count_view.sql [deleted file]

index 1b9305e..3ff4d76 100644 (file)
@@ -57,7 +57,7 @@ CREATE TABLE config.upgrade_log (
     install_date    TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
 );
 
-INSERT INTO config.upgrade_log (version) VALUES ('0646'); -- jamesrf/senator
+INSERT INTO config.upgrade_log (version) VALUES ('0649'); -- dbwells/tsbere/miker
 
 CREATE TABLE config.bib_source (
        id              SERIAL  PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/0649.schema.fix_full_circ_count_view.sql b/Open-ILS/src/sql/Pg/upgrade/0649.schema.fix_full_circ_count_view.sql
new file mode 100644 (file)
index 0000000..98b789f
--- /dev/null
@@ -0,0 +1,14 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0649');
+
+CREATE OR REPLACE VIEW extend_reporter.full_circ_count AS
+ SELECT cp.id, COALESCE(c.circ_count, 0::bigint) + COALESCE(count(DISTINCT circ.id), 0::bigint) + COALESCE(count(DISTINCT acirc.id), 0::bigint) AS circ_count
+   FROM asset."copy" cp
+   LEFT JOIN extend_reporter.legacy_circ_count c USING (id)
+   LEFT JOIN "action".circulation circ ON circ.target_copy = cp.id
+   LEFT JOIN "action".aged_circulation acirc ON acirc.target_copy = cp.id
+  GROUP BY cp.id, c.circ_count;
+
+COMMIT;
+
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.fix_full_circ_count_view.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.fix_full_circ_count_view.sql
deleted file mode 100644 (file)
index 2107adc..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-CREATE OR REPLACE VIEW extend_reporter.full_circ_count AS
- SELECT cp.id, COALESCE(c.circ_count, 0::bigint) + COALESCE(count(DISTINCT circ.id), 0::bigint) + COALESCE(count(DISTINCT acirc.id), 0::bigint) AS circ_count
-   FROM asset."copy" cp
-   LEFT JOIN extend_reporter.legacy_circ_count c USING (id)
-   LEFT JOIN "action".circulation circ ON circ.target_copy = cp.id
-   LEFT JOIN "action".aged_circulation acirc ON acirc.target_copy = cp.id
-  GROUP BY cp.id, c.circ_count;