From a2cd9b1d7c99a30d8d124065c34a1667457a9e43 Mon Sep 17 00:00:00 2001
From: miker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Date: Mon, 1 Nov 2010 17:32:15 +0000
Subject: [PATCH] keep 1.6.1-2.0 upgrade script in sync

git-svn-id: svn://svn.open-ils.org/ILS/trunk@18552 dcc99617-32d9-48b4-a31d-7c20da2025e4
---
 Open-ILS/src/sql/Pg/1.6.1-2.0-upgrade-db.sql | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/Open-ILS/src/sql/Pg/1.6.1-2.0-upgrade-db.sql b/Open-ILS/src/sql/Pg/1.6.1-2.0-upgrade-db.sql
index ed35d024ed..8001697120 100644
--- a/Open-ILS/src/sql/Pg/1.6.1-2.0-upgrade-db.sql
+++ b/Open-ILS/src/sql/Pg/1.6.1-2.0-upgrade-db.sql
@@ -6556,26 +6556,31 @@ BEGIN
 
             -- caclulate the rule match weight
             IF current_mp.item_owning_ou IS NOT NULL THEN
+                CONTINUE WHEN current_mp.item_owning_ou NOT IN (SELECT (actor.org_unit_ancestors(item_cn_object.owning_lib)).id);
                 SELECT INTO tmp_weight 1.0 / (actor.org_unit_proximity(current_mp.item_owning_ou, item_cn_object.owning_lib)::FLOAT + 1.0)::FLOAT;
                 current_mp_weight := current_mp_weight - tmp_weight;
             END IF; 
 
             IF current_mp.item_circ_ou IS NOT NULL THEN
+                CONTINUE WHEN current_mp.item_circ_ou NOT IN (SELECT (actor.org_unit_ancestors(item_object.circ_lib)).id);
                 SELECT INTO tmp_weight 1.0 / (actor.org_unit_proximity(current_mp.item_circ_ou, item_object.circ_lib)::FLOAT + 1.0)::FLOAT;
                 current_mp_weight := current_mp_weight - tmp_weight;
             END IF; 
 
             IF current_mp.pickup_ou IS NOT NULL THEN
+                CONTINUE WHEN current_mp.pickup_ou NOT IN (SELECT (actor.org_unit_ancestors(pickup_ou)).id);
                 SELECT INTO tmp_weight 1.0 / (actor.org_unit_proximity(current_mp.pickup_ou, pickup_ou)::FLOAT + 1.0)::FLOAT;
                 current_mp_weight := current_mp_weight - tmp_weight;
             END IF; 
 
             IF current_mp.request_ou IS NOT NULL THEN
+                CONTINUE WHEN current_mp.request_ou NOT IN (SELECT (actor.org_unit_ancestors(request_ou)).id);
                 SELECT INTO tmp_weight 1.0 / (actor.org_unit_proximity(current_mp.request_ou, request_ou)::FLOAT + 1.0)::FLOAT;
                 current_mp_weight := current_mp_weight - tmp_weight;
             END IF; 
 
             IF current_mp.user_home_ou IS NOT NULL THEN
+                CONTINUE WHEN current_mp.user_home_ou NOT IN (SELECT (actor.org_unit_ancestors(user_object.home_ou)).id);
                 SELECT INTO tmp_weight 1.0 / (actor.org_unit_proximity(current_mp.user_home_ou, user_object.home_ou)::FLOAT + 1.0)::FLOAT;
                 current_mp_weight := current_mp_weight - tmp_weight;
             END IF; 
@@ -18867,3 +18872,4 @@ INSERT INTO action_trigger.event_definition (
 
 \qecho Upgrade script completed.
 
+
-- 
2.11.0