[open-ils-commits] r17504 - branches/rel_2_0/Open-ILS/src/sql/Pg (scottmk)

svn at svn.open-ils.org svn at svn.open-ils.org
Tue Sep 7 15:53:00 EDT 2010


Author: scottmk
Date: 2010-09-07 15:52:55 -0400 (Tue, 07 Sep 2010)
New Revision: 17504

Modified:
   branches/rel_2_0/Open-ILS/src/sql/Pg/1.6.1-2.0-upgrade-db.sql
Log:
The reporter and extend_reporter schemas are no longer optional.
So changes to them go back into the transaction.

ALTERs to auditor.action_hold_request_history stay outside of the
transaction, at least for now, until the status of that table
is clarified.



Modified: branches/rel_2_0/Open-ILS/src/sql/Pg/1.6.1-2.0-upgrade-db.sql
===================================================================
--- branches/rel_2_0/Open-ILS/src/sql/Pg/1.6.1-2.0-upgrade-db.sql	2010-09-07 16:54:44 UTC (rev 17503)
+++ branches/rel_2_0/Open-ILS/src/sql/Pg/1.6.1-2.0-upgrade-db.sql	2010-09-07 19:52:55 UTC (rev 17504)
@@ -1,10 +1,3 @@
--- Drop a view temporarily in order to alter action.all_circulation, upon
--- which it is dependent.  This drop is outside the transaction because the
--- extend_reporter schema may not exist in a given database.  We will recreate
--- the view later, after the transaction.
-
-DROP VIEW IF EXISTS extend_reporter.full_circ_count;
-
 BEGIN;
 
 -- Highest-numbered individual upgrade script
@@ -4976,6 +4969,11 @@
 
 -- Extend the name change to some related views:
 
+-- Drop a view temporarily in order to alter action.all_circulation, upon
+-- which it is dependent.  We will recreate the view later.
+
+DROP VIEW IF EXISTS extend_reporter.full_circ_count;
+
 -- You would think that CREATE OR REPLACE would be enough, but in testing
 -- PostgreSQL complained about renaming the columns in the view. So we
 -- drop the view first.
@@ -5004,6 +5002,16 @@
         LEFT JOIN actor.usr_address a ON (p.mailing_address = a.id)
         LEFT JOIN actor.usr_address b ON (p.billing_address = a.id);
 
+-- Recreate the temporarily dropped view, having altered the action.all_circulation view:
+
+CREATE OR REPLACE VIEW extend_reporter.full_circ_count AS
+ SELECT cp.id, COALESCE(sum(c.circ_count), 0::bigint) + COALESCE(count(circ.id), 0::bigint) + COALESCE(count(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;
+
 CREATE UNIQUE INDEX only_one_concurrent_checkout_per_copy ON action.circulation(target_copy) WHERE checkin_time IS NULL;
 
 ALTER TABLE action.circulation DROP CONSTRAINT action_circulation_target_copy_fkey;
@@ -16424,30 +16432,8 @@
 ALTER TABLE asset.copy_location ADD COLUMN label_prefix TEXT;
 ALTER TABLE asset.copy_location ADD COLUMN label_suffix TEXT;
 
-COMMIT;
-
--- Outside of the commit: various things that may legitimately fail.
-
-ALTER TABLE auditor.action_hold_request_history ADD COLUMN cut_in_line BOOL;
-
-ALTER TABLE auditor.action_hold_request_history
-ADD COLUMN mint_condition boolean NOT NULL DEFAULT TRUE;
-
-ALTER TABLE auditor.action_hold_request_history
-ADD COLUMN shelf_expire_time TIMESTAMPTZ;
-
 ALTER TABLE reporter.report RENAME COLUMN recurance TO recurrence;
 
--- Recreate the temporarily dropped view, having altered the action.all_circulation view:
-
-CREATE OR REPLACE VIEW extend_reporter.full_circ_count AS
- SELECT cp.id, COALESCE(sum(c.circ_count), 0::bigint) + COALESCE(count(circ.id), 0::bigint) + COALESCE(count(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;
-
 -- Let's not break existing reports
 UPDATE reporter.template SET data = REGEXP_REPLACE(data, E'^(.*)recuring(.*)$', E'\\1recurring\\2') WHERE data LIKE '%recuring%';
 UPDATE reporter.template SET data = REGEXP_REPLACE(data, E'^(.*)recurance(.*)$', E'\\1recurrence\\2') WHERE data LIKE '%recurance%';
@@ -16532,3 +16518,16 @@
 CREATE TRIGGER bbb_simple_rec_trigger AFTER INSERT OR UPDATE ON biblio.record_entry FOR EACH ROW EXECUTE PROCEDURE reporter.simple_rec_trigger ();
 
 ALTER TABLE extend_reporter.legacy_circ_count DROP CONSTRAINT legacy_circ_count_id_fkey;
+
+COMMIT;
+
+-- Outside of the commit: some alters that may legitimately fail
+-- if the table doesn't exist.
+
+ALTER TABLE auditor.action_hold_request_history ADD COLUMN cut_in_line BOOL;
+
+ALTER TABLE auditor.action_hold_request_history
+ADD COLUMN mint_condition boolean NOT NULL DEFAULT TRUE;
+
+ALTER TABLE auditor.action_hold_request_history
+ADD COLUMN shelf_expire_time TIMESTAMPTZ;



More information about the open-ils-commits mailing list