[open-ils-commits] [GIT] Evergreen ILS branch rel_2_10 updated. aabe6f8d397873e07734cb0642f92c0f053514a2

Evergreen Git git at git.evergreen-ils.org
Wed Apr 27 10:40:50 EDT 2016


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, rel_2_10 has been updated
       via  aabe6f8d397873e07734cb0642f92c0f053514a2 (commit)
       via  9a87f5241b722336ba194a9146fdd79a38474f91 (commit)
       via  95def1984b4ccded97a0657e8196d4d4e95e96d7 (commit)
      from  f49bdab6743fbcf44492b0e6ce2a35721b9c8195 (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 aabe6f8d397873e07734cb0642f92c0f053514a2
Author: Kathy Lussier <klussier at masslnc.org>
Date:   Wed Apr 27 10:35:49 2016 -0400

    LP#1564079 Stamping upgrade script
    
    Signed-off-by: Kathy Lussier <klussier at masslnc.org>

diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql
index 344c316..2a92f1c 100644
--- a/Open-ILS/src/sql/Pg/002.schema.config.sql
+++ b/Open-ILS/src/sql/Pg/002.schema.config.sql
@@ -91,7 +91,7 @@ CREATE TRIGGER no_overlapping_deps
     BEFORE INSERT OR UPDATE ON config.db_patch_dependencies
     FOR EACH ROW EXECUTE PROCEDURE evergreen.array_overlap_check ('deprecates');
 
-INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0975', :eg_version); -- gmcharlt/dbwells
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0976', :eg_version); -- berick/kmlussier
 
 CREATE TABLE config.bib_source (
 	id		SERIAL	PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.fix_circ_history_copy_ref.sql b/Open-ILS/src/sql/Pg/upgrade/0976.schema.fix_circ_history_copy_ref.sql
similarity index 82%
rename from Open-ILS/src/sql/Pg/upgrade/XXXX.schema.fix_circ_history_copy_ref.sql
rename to Open-ILS/src/sql/Pg/upgrade/0976.schema.fix_circ_history_copy_ref.sql
index 2acd1dd..7770a75 100644
--- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.fix_circ_history_copy_ref.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/0976.schema.fix_circ_history_copy_ref.sql
@@ -1,7 +1,6 @@
-
 BEGIN;
 
---SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+SELECT evergreen.upgrade_deps_block_check('0976', :eg_version);
 
 ALTER TABLE action.usr_circ_history 
     DROP CONSTRAINT IF EXISTS usr_circ_history_target_copy_fkey;

commit 9a87f5241b722336ba194a9146fdd79a38474f91
Author: Bill Erickson <berickxx at gmail.com>
Date:   Wed Mar 30 17:57:59 2016 -0400

    LP#1564079 Checkout history skips nonexistent items
    
    Modify the user checkout history migration process
    (2.9.3-2.10.0-upgrade-db.sql and 0960.schema.decouple_co_history.sql) to
    avoid inserting history rows for circulations whose copies do not
    exist in the database.
    
    For reference, this is a rare condition that cannot be recreated in a
    modern EG system short of modifying constraints.
    
    Signed-off-by: Bill Erickson <berickxx at gmail.com>
    Signed-off-by: Kathy Lussier <klussier at masslnc.org>

diff --git a/Open-ILS/src/sql/Pg/upgrade/0960.schema.decouple_co_history.sql b/Open-ILS/src/sql/Pg/upgrade/0960.schema.decouple_co_history.sql
index 59e13b7..135c244 100644
--- a/Open-ILS/src/sql/Pg/upgrade/0960.schema.decouple_co_history.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/0960.schema.decouple_co_history.sql
@@ -213,6 +213,14 @@ BEGIN
 
         FOR cur_circ IN SELECT * FROM action.usr_visible_circs(cur_usr) LOOP
 
+            PERFORM TRUE FROM asset.copy WHERE id = cur_circ.target_copy;
+
+            -- Avoid inserting a circ history row when the circulated
+            -- item has been (forcibly) removed from the database.
+            IF NOT FOUND THEN
+                CONTINUE;
+            END IF;
+
             -- Find the last circ in the circ chain.
             SELECT INTO last_circ * 
                 FROM action.circ_chain(cur_circ.id) 
diff --git a/Open-ILS/src/sql/Pg/version-upgrade/2.9.3-2.10.0-upgrade-db.sql b/Open-ILS/src/sql/Pg/version-upgrade/2.9.3-2.10.0-upgrade-db.sql
index 7440667..9ed7e22 100644
--- a/Open-ILS/src/sql/Pg/version-upgrade/2.9.3-2.10.0-upgrade-db.sql
+++ b/Open-ILS/src/sql/Pg/version-upgrade/2.9.3-2.10.0-upgrade-db.sql
@@ -1527,6 +1527,14 @@ BEGIN
 
         FOR cur_circ IN SELECT * FROM action.usr_visible_circs(cur_usr) LOOP
 
+            PERFORM TRUE FROM asset.copy WHERE id = cur_circ.target_copy;
+
+            -- Avoid inserting a circ history row when the circulated
+            -- item has been (forcibly) removed from the database.
+            IF NOT FOUND THEN
+                CONTINUE;
+            END IF;
+
             -- Find the last circ in the circ chain.
             SELECT INTO last_circ * 
                 FROM action.circ_chain(cur_circ.id) 

commit 95def1984b4ccded97a0657e8196d4d4e95e96d7
Author: Bill Erickson <berickxx at gmail.com>
Date:   Wed Mar 30 17:49:26 2016 -0400

    LP#1564079 Checkout history handles serials
    
    Remove the target_copy foreign key constraint on action.usr_circ_history
    so that it does not prevent creation of rows from circulation's that
    link to serial.unit objects.  Similar to action.circulation, the foreign
    key constraint is enforced via a evergreen.fake_fkey_tgr trigger
    instead.
    
    This modifies the 2.9.3-2.10.0-upgrade-db.sql and 0960 upgrade scripts,
    since without this change, the scripts may fail.
    
    A separate upgrade script is added to drop the constraint for those who
    have already successfully run the the 2.9.3-2.10.0-upgrade-db.sql script
    (i.e. those who don't use serials).  For simplicity, the
    evergreen.fake_fkey_tgr trigger is only applied in this separate upgrade
    script (in addition to the base schema, of course).
    
    Signed-off-by: Bill Erickson <berickxx at gmail.com>
    Signed-off-by: Kathy Lussier <klussier at masslnc.org>

diff --git a/Open-ILS/src/sql/Pg/090.schema.action.sql b/Open-ILS/src/sql/Pg/090.schema.action.sql
index f203aa9..74b2ca4 100644
--- a/Open-ILS/src/sql/Pg/090.schema.action.sql
+++ b/Open-ILS/src/sql/Pg/090.schema.action.sql
@@ -1311,14 +1311,17 @@ CREATE TABLE action.usr_circ_history (
     usr          INTEGER NOT NULL REFERENCES actor.usr(id)
                  DEFERRABLE INITIALLY DEFERRED,
     xact_start   TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
-    target_copy  BIGINT NOT NULL REFERENCES asset.copy(id)
-                 DEFERRABLE INITIALLY DEFERRED,
+    target_copy  BIGINT NOT NULL, -- asset.copy.id / serial.unit.id
     due_date     TIMESTAMP WITH TIME ZONE NOT NULL,
     checkin_time TIMESTAMP WITH TIME ZONE,
     source_circ  BIGINT REFERENCES action.circulation(id)
                  ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED
 );
 
+CREATE TRIGGER action_usr_circ_history_target_copy_trig 
+    AFTER INSERT OR UPDATE ON action.usr_circ_history 
+    FOR EACH ROW EXECUTE PROCEDURE evergreen.fake_fkey_tgr('target_copy');
+
 CREATE OR REPLACE FUNCTION action.maintain_usr_circ_history() 
     RETURNS TRIGGER AS $FUNK$
 DECLARE
diff --git a/Open-ILS/src/sql/Pg/upgrade/0960.schema.decouple_co_history.sql b/Open-ILS/src/sql/Pg/upgrade/0960.schema.decouple_co_history.sql
index 5fc0fed..59e13b7 100644
--- a/Open-ILS/src/sql/Pg/upgrade/0960.schema.decouple_co_history.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/0960.schema.decouple_co_history.sql
@@ -11,8 +11,7 @@ CREATE TABLE action.usr_circ_history (
     usr          INTEGER NOT NULL REFERENCES actor.usr(id)
                  DEFERRABLE INITIALLY DEFERRED,
     xact_start   TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
-    target_copy  BIGINT NOT NULL REFERENCES asset.copy(id)
-                 DEFERRABLE INITIALLY DEFERRED,
+    target_copy  BIGINT NOT NULL,
     due_date     TIMESTAMP WITH TIME ZONE NOT NULL,
     checkin_time TIMESTAMP WITH TIME ZONE,
     source_circ  BIGINT REFERENCES action.circulation(id)
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.fix_circ_history_copy_ref.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.fix_circ_history_copy_ref.sql
new file mode 100644
index 0000000..2acd1dd
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.fix_circ_history_copy_ref.sql
@@ -0,0 +1,14 @@
+
+BEGIN;
+
+--SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+ALTER TABLE action.usr_circ_history 
+    DROP CONSTRAINT IF EXISTS usr_circ_history_target_copy_fkey;
+
+CREATE TRIGGER action_usr_circ_history_target_copy_trig 
+    AFTER INSERT OR UPDATE ON action.usr_circ_history 
+    FOR EACH ROW EXECUTE PROCEDURE evergreen.fake_fkey_tgr('target_copy');
+
+COMMIT;
+
diff --git a/Open-ILS/src/sql/Pg/version-upgrade/2.9.3-2.10.0-upgrade-db.sql b/Open-ILS/src/sql/Pg/version-upgrade/2.9.3-2.10.0-upgrade-db.sql
index 0856094..7440667 100644
--- a/Open-ILS/src/sql/Pg/version-upgrade/2.9.3-2.10.0-upgrade-db.sql
+++ b/Open-ILS/src/sql/Pg/version-upgrade/2.9.3-2.10.0-upgrade-db.sql
@@ -1325,8 +1325,7 @@ CREATE TABLE action.usr_circ_history (
     usr          INTEGER NOT NULL REFERENCES actor.usr(id)
                  DEFERRABLE INITIALLY DEFERRED,
     xact_start   TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
-    target_copy  BIGINT NOT NULL REFERENCES asset.copy(id)
-                 DEFERRABLE INITIALLY DEFERRED,
+    target_copy  BIGINT NOT NULL,
     due_date     TIMESTAMP WITH TIME ZONE NOT NULL,
     checkin_time TIMESTAMP WITH TIME ZONE,
     source_circ  BIGINT REFERENCES action.circulation(id)

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

Summary of changes:
 Open-ILS/src/sql/Pg/002.schema.config.sql          |    2 +-
 Open-ILS/src/sql/Pg/090.schema.action.sql          |    7 +++++--
 .../Pg/upgrade/0960.schema.decouple_co_history.sql |   11 +++++++++--
 .../0976.schema.fix_circ_history_copy_ref.sql      |   13 +++++++++++++
 .../Pg/version-upgrade/2.9.3-2.10.0-upgrade-db.sql |   11 +++++++++--
 5 files changed, 37 insertions(+), 7 deletions(-)
 create mode 100644 Open-ILS/src/sql/Pg/upgrade/0976.schema.fix_circ_history_copy_ref.sql


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list