[open-ils-commits] r15393 - in trunk/Open-ILS/src/sql/Pg: . upgrade (scottmk)
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Jan 27 16:31:17 EST 2010
Author: scottmk
Date: 2010-01-27 16:31:12 -0500 (Wed, 27 Jan 2010)
New Revision: 15393
Added:
trunk/Open-ILS/src/sql/Pg/upgrade/0141.schema.acq.fund_debit_total_view.sql
Modified:
trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
trunk/Open-ILS/src/sql/Pg/200.schema.acq.sql
Log:
Redefine the view acq.fund_debit_total:
1. Correct the mistaken use of acq.fund_debit.id for fund,
instead of acq.fund_debit.fund.
2. Join to acq.fund so that we get a zero total for a fund
with no debits in acq.fund_debit.
Four other views are affected indirectly because they are defined
in terms of acq.fund_debit_total:
fund_encumbrance_total
fund_spent_total
fund_spent_balance
fund_combined_balance
M Open-ILS/src/sql/Pg/200.schema.acq.sql
M Open-ILS/src/sql/Pg/002.schema.config.sql
A Open-ILS/src/sql/Pg/upgrade/0141.schema.acq.fund_debit_total_view.sql
Modified: trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2010-01-27 21:18:56 UTC (rev 15392)
+++ trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2010-01-27 21:31:12 UTC (rev 15393)
@@ -51,7 +51,7 @@
install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
);
-INSERT INTO config.upgrade_log (version) VALUES ('0140'); -- Scott McKellar
+INSERT INTO config.upgrade_log (version) VALUES ('0141'); -- Scott McKellar
CREATE TABLE config.bib_source (
id SERIAL PRIMARY KEY,
Modified: trunk/Open-ILS/src/sql/Pg/200.schema.acq.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/200.schema.acq.sql 2010-01-27 21:18:56 UTC (rev 15392)
+++ trunk/Open-ILS/src/sql/Pg/200.schema.acq.sql 2010-01-27 21:31:12 UTC (rev 15393)
@@ -849,10 +849,12 @@
GROUP BY 1;
CREATE OR REPLACE VIEW acq.fund_debit_total AS
- SELECT id AS fund,
- encumbrance,
- SUM(amount) AS amount
- FROM acq.fund_debit
+ SELECT fund.id AS fund,
+ fund_debit.encumbrance AS encumbrance,
+ COALESCE( SUM(fund_debit.amount), 0 ) AS amount
+ FROM acq.fund AS fund
+ LEFT JOIN acq.fund_debit AS fund_debit
+ ON ( fund.id = fund_debit.fund )
GROUP BY 1,2;
CREATE OR REPLACE VIEW acq.fund_encumbrance_total AS
Added: trunk/Open-ILS/src/sql/Pg/upgrade/0141.schema.acq.fund_debit_total_view.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/upgrade/0141.schema.acq.fund_debit_total_view.sql (rev 0)
+++ trunk/Open-ILS/src/sql/Pg/upgrade/0141.schema.acq.fund_debit_total_view.sql 2010-01-27 21:31:12 UTC (rev 15393)
@@ -0,0 +1,14 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0141'); -- Scott McKellar
+
+CREATE OR REPLACE VIEW acq.fund_debit_total AS
+ SELECT fund.id AS fund,
+ fund_debit.encumbrance AS encumbrance,
+ COALESCE( SUM(fund_debit.amount), 0 ) AS amount
+ FROM acq.fund AS fund
+ LEFT JOIN acq.fund_debit AS fund_debit
+ ON ( fund.id = fund_debit.fund )
+ GROUP BY 1,2;
+
+COMMIT;
More information about the open-ils-commits
mailing list