---
--- PostgreSQL database dump
---
-/*
-Generated 2014-12-22
-pg_dump -U evergreen evergreen -s > kcls-eg-db-schema.sql
-*/
--- These may already exist.
-CREATE USER bbonner; -- custom
-CREATE USER biblio; -- custom
-CREATE USER kclsreporter; -- custom
-CREATE USER kclsreporter2; -- custom
+-- Generated 2015-01-08 08:09:42 on db03.eg.kcls.org
+
+-- These custom users may already exist... errors are OK.
+
+CREATE USER bbonner;
+CREATE USER biblio;
+CREATE USER kclsreporter;
+CREATE USER kclsreporter2;
BEGIN;
-\set ON_ERROR_STOP on;
+\set ON_ERROR_STOP on
+
--- PGDUMP output begins here...
+--
+-- PostgreSQL database dump
+--
SET statement_timeout = 0;
SET client_encoding = 'UTF8';
COMMENT ON EXTENSION pg_buffercache IS 'examine the shared buffer cache';
+
/*
--
-- Name: pg_prewarm; Type: EXTENSION; Schema: -; Owner:
ALTER FUNCTION collectionhq.write_bib_rows_to_stdout(text, integer) OWNER TO evergreen;
--
--- Name: write_item_rows_to_stdout(text, integer); Type: FUNCTION; Schema: collectionhq; Owner: evergreen
+-- Name: write_item_rows_to_stdout(text, integer); Type: FUNCTION; Schema: collectionhq; Owner: postgres
--
CREATE FUNCTION write_item_rows_to_stdout(text, integer) RETURNS text
SELECT REPLACE(NOW()::DATE::TEXT, '-', '') INTO extract_date;
FOR item, arrived, cumulative_use_total IN
- SELECT cp.id, dest_recv_time, COALESCE(sum(c.circ_count), 0::bigint) + COALESCE(count(circ.id), 0::bigint) + COALESCE(count(acirc.id), 0::bigint) AS circ_count
+ SELECT cp.id, dest_recv_time, COALESCE(sum(DISTINCT 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 (SELECT max(dest_recv_time) as dest_recv_time, target_copy, dest from action.transit_copy group by target_copy, dest) atc ON (cp.id = atc.target_copy AND cp.circ_lib = atc.dest)
RAISE INFO '% rows written in total.', num_rows;
RETURN '';
-
END;
$_$;
-ALTER FUNCTION collectionhq.write_item_rows_to_stdout(text, integer) OWNER TO evergreen;
+ALTER FUNCTION collectionhq.write_item_rows_to_stdout(text, integer) OWNER TO postgres;
--
-- Name: write_item_rows_to_stdout_new(text, integer); Type: FUNCTION; Schema: collectionhq; Owner: postgres
-- PostgreSQL database dump complete
--
+
COMMIT;
+