codification of a new namespace for customizations to the reporter schema, with an...
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 13 Jun 2008 13:30:48 +0000 (13:30 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 13 Jun 2008 13:30:48 +0000 (13:30 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_2_2@9825 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/sql/Pg/1.2.2.1-1.2.2.2-upgrade-db.sql [new file with mode: 0644]
Open-ILS/src/sql/Pg/extend-reporter.sql [new file with mode: 0644]

diff --git a/Open-ILS/src/sql/Pg/1.2.2.1-1.2.2.2-upgrade-db.sql b/Open-ILS/src/sql/Pg/1.2.2.1-1.2.2.2-upgrade-db.sql
new file mode 100644 (file)
index 0000000..cb6adb3
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2008  Equinox Software, Inc.
+ * Mike Rylander <miker@esilibrary.com.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+BEGIN;
+
+CREATE SCHEMA extend_reporter;
+
+CREATE TABLE extend_reporter.legcay_circ_count (
+    id          BIGSERIAL   PRIMARY KEY REFERENCES asset.copy (id)
+    circ_count  INT         NOT NULL DEFAULT 0
+);
+
+CREATE VIEW extend_reporter.full_circ_count AS
+ SELECT cp.id, COALESCE(sum(c.circ_count), 0::bigint) + COALESCE(count(circ.id), 0::bigint) AS circ_count
+   FROM asset."copy" cp
+   LEFT JOIN extend_reporter.legcay_circ_count c USING (id)
+   LEFT JOIN "action".circulation circ ON circ.target_copy = c.id
+  GROUP BY cp.id;
+
+COMMIT;
+
diff --git a/Open-ILS/src/sql/Pg/extend-reporter.sql b/Open-ILS/src/sql/Pg/extend-reporter.sql
new file mode 100644 (file)
index 0000000..90fcd2d
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2008  Equinox Software, Inc.
+ * Mike Rylander <miker@esilibrary.com> 
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+DROP SCHEMA extend_reporter CASCADE;
+
+BEGIN;
+
+CREATE SCHEMA extend_reporter;
+
+CREATE TABLE extend_reporter.legcay_circ_count (
+    id          BIGSERIAL   PRIMARY KEY REFERENCES asset.copy (id)
+    circ_count  INT         NOT NULL DEFAULT 0
+);
+
+CREATE VIEW extend_reporter.full_circ_count AS
+ SELECT cp.id, COALESCE(sum(c.circ_count), 0::bigint) + COALESCE(count(circ.id), 0::bigint) AS circ_count
+   FROM asset."copy" cp
+   LEFT JOIN extend_reporter.legcay_circ_count c USING (id)
+   LEFT JOIN "action".circulation circ ON circ.target_copy = c.id
+  GROUP BY cp.id;
+
+COMMIT;
+