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,
--- /dev/null
+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;
+
+++ /dev/null
-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;