[open-ils-commits] [GIT] Evergreen ILS branch master updated. 148c06c17527bac8d37dae5f4d1d9b2ea9011405

Evergreen Git git at git.evergreen-ils.org
Wed Feb 29 13:42:26 EST 2012


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, master has been updated
       via  148c06c17527bac8d37dae5f4d1d9b2ea9011405 (commit)
      from  5b7b588c3e41b522f39c46deb2ba48cc92acf9ea (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 148c06c17527bac8d37dae5f4d1d9b2ea9011405
Author: Thomas Berezansky <tsbere at mvlc.org>
Date:   Mon Jan 9 13:58:07 2012 -0500

    Speed up 0663 upgrade script
    
    Move update to the end
    
    This ensures most of the rest goes without error first
    
    Disable triggers on the table before doing update
    
    This speeds the update up significantly as we don't need to re-calc the
    additional column's new data.
    
    Allow new column to be null (at first) with no default
    
    This allows the column to be added *without* re-writing every row. We still
    re-write every row with the update, but at least we aren't doing that
    *twice* this way.
    
    And add the not null/default to new column and re-enable triggers as our
    last action.
    
    Signed-off-by: Thomas Berezansky <tsbere at mvlc.org>
    Signed-off-by: Jason Stephenson <jstephenson at mvlc.org>

diff --git a/Open-ILS/src/sql/Pg/upgrade/0663.schema.archive_circ_stat_cats.sql b/Open-ILS/src/sql/Pg/upgrade/0663.schema.archive_circ_stat_cats.sql
index 022b2dd..192b359 100644
--- a/Open-ILS/src/sql/Pg/upgrade/0663.schema.archive_circ_stat_cats.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/0663.schema.archive_circ_stat_cats.sql
@@ -34,10 +34,7 @@ ALTER TABLE asset.stat_cat
 
 -- Circulation copy column
 ALTER TABLE action.circulation
-    ADD COLUMN copy_location INT NOT NULL DEFAULT 1 REFERENCES asset.copy_location(id) DEFERRABLE INITIALLY DEFERRED;
-
--- Update action.circulation with real copy_location numbers instead of all "Stacks"
-UPDATE action.circulation circ SET copy_location = ac.location FROM asset.copy ac WHERE ac.id = circ.target_copy;
+    ADD COLUMN copy_location INT NULL REFERENCES asset.copy_location(id) DEFERRABLE INITIALLY DEFERRED;
 
 -- Create trigger function to auto-fill the copy_location field
 CREATE OR REPLACE FUNCTION action.fill_circ_copy_location () RETURNS TRIGGER AS $$
@@ -69,6 +66,9 @@ $$ LANGUAGE PLPGSQL;
 CREATE TRIGGER fill_circ_copy_location_tgr BEFORE INSERT ON action.circulation FOR EACH ROW EXECUTE PROCEDURE action.fill_circ_copy_location();
 CREATE TRIGGER archive_stat_cats_tgr AFTER INSERT ON action.circulation FOR EACH ROW EXECUTE PROCEDURE action.archive_stat_cats();
 
+-- Ensure all triggers are disabled for speedy updates!
+ALTER TABLE action.circulation DISABLE TRIGGER ALL;
+
 -- Update view to use circ's copy_location field instead of the copy's current copy_location field
 CREATE OR REPLACE VIEW action.all_circulation AS
     SELECT  id,usr_post_code, usr_home_ou, usr_profile, usr_birth_year, copy_call_number, copy_location,
@@ -93,4 +93,14 @@ CREATE OR REPLACE VIEW action.all_circulation AS
         LEFT JOIN actor.usr_address a ON (p.mailing_address = a.id)
         LEFT JOIN actor.usr_address b ON (p.billing_address = b.id);
 
+-- Update action.circulation with real copy_location numbers instead of all NULL
+DO $$BEGIN RAISE WARNING 'We are about to do an update on every row in action.circulation. This may take a while. %', timeofday(); END;$$;
+UPDATE action.circulation circ SET copy_location = ac.location FROM asset.copy ac WHERE ac.id = circ.target_copy;
+
+-- Set not null/default on new column, re-enable triggers
+ALTER TABLE action.circulation
+    ALTER COLUMN copy_location SET NOT NULL,
+    ALTER COLUMN copy_location SET DEFAULT 1,
+    ENABLE TRIGGER ALL;
+
 COMMIT;

-----------------------------------------------------------------------

Summary of changes:
 .../upgrade/0663.schema.archive_circ_stat_cats.sql |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list