Stamping the upgrade script for in-db OU proximity update
authorMike Rylander <mrylander@gmail.com>
Wed, 7 Sep 2011 18:10:56 +0000 (14:10 -0400)
committerMike Rylander <mrylander@gmail.com>
Wed, 7 Sep 2011 18:10:56 +0000 (14:10 -0400)
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/src/sql/Pg/002.schema.config.sql
Open-ILS/src/sql/Pg/upgrade/0616.schema.actor_org_unit_trigger_prox_update.sql [new file with mode: 0644]
Open-ILS/src/sql/Pg/upgrade/xxxx.schema.actor_org_unit_trigger_prox_update.sql [deleted file]

index 5c4cd1e..dafba05 100644 (file)
@@ -86,7 +86,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 ('0615', :eg_version); -- miker/berick
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0616', :eg_version); -- miker/stevecallender
 
 CREATE TABLE config.bib_source (
        id              SERIAL  PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/0616.schema.actor_org_unit_trigger_prox_update.sql b/Open-ILS/src/sql/Pg/upgrade/0616.schema.actor_org_unit_trigger_prox_update.sql
new file mode 100644 (file)
index 0000000..c3aab88
--- /dev/null
@@ -0,0 +1,46 @@
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('0616', :eg_version);
+
+CREATE OR REPLACE FUNCTION actor.org_unit_prox_update () RETURNS TRIGGER as $$
+BEGIN
+
+
+IF TG_OP = 'DELETE' THEN
+
+    DELETE FROM actor.org_unit_proximity WHERE (from_org = OLD.id or to_org= OLD.id);
+
+END IF;
+
+IF TG_OP = 'UPDATE' THEN
+
+    IF NEW.parent_ou <> OLD.parent_ou THEN
+
+        DELETE FROM actor.org_unit_proximity WHERE (from_org = OLD.id or to_org= OLD.id);
+            INSERT INTO actor.org_unit_proximity (from_org, to_org, prox)
+            SELECT  l.id, r.id, actor.org_unit_proximity(l.id,r.id)
+                FROM  actor.org_unit l, actor.org_unit r
+                WHERE (l.id = NEW.id or r.id = NEW.id);
+
+    END IF;
+
+END IF;
+
+IF TG_OP = 'INSERT' THEN
+
+     INSERT INTO actor.org_unit_proximity (from_org, to_org, prox)
+     SELECT  l.id, r.id, actor.org_unit_proximity(l.id,r.id)
+         FROM  actor.org_unit l, actor.org_unit r
+         WHERE (l.id = NEW.id or r.id = NEW.id);
+
+END IF;
+
+RETURN null;
+
+END;
+$$ LANGUAGE plpgsql;
+
+
+CREATE TRIGGER proximity_update_tgr AFTER INSERT OR UPDATE OR DELETE ON actor.org_unit FOR EACH ROW EXECUTE PROCEDURE actor.org_unit_prox_update ();
+
+COMMIT;
diff --git a/Open-ILS/src/sql/Pg/upgrade/xxxx.schema.actor_org_unit_trigger_prox_update.sql b/Open-ILS/src/sql/Pg/upgrade/xxxx.schema.actor_org_unit_trigger_prox_update.sql
deleted file mode 100644 (file)
index dd0e2b9..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-BEGIN;
-
-INSERT INTO config.upgrade_log (version) VALUES ('XXX'); -- stevecallender
-
-CREATE OR REPLACE FUNCTION actor.org_unit_prox_update () RETURNS TRIGGER as $$
-BEGIN
-
-
-IF TG_OP = 'DELETE' THEN
-
-    DELETE FROM actor.org_unit_proximity WHERE (from_org = OLD.id or to_org= OLD.id);
-
-END IF;
-
-IF TG_OP = 'UPDATE' THEN
-
-    IF NEW.parent_ou <> OLD.parent_ou THEN
-
-        DELETE FROM actor.org_unit_proximity WHERE (from_org = OLD.id or to_org= OLD.id);
-            INSERT INTO actor.org_unit_proximity (from_org, to_org, prox)
-            SELECT  l.id, r.id, actor.org_unit_proximity(l.id,r.id)
-                FROM  actor.org_unit l, actor.org_unit r
-                WHERE (l.id = NEW.id or r.id = NEW.id);
-
-    END IF;
-
-END IF;
-
-IF TG_OP = 'INSERT' THEN
-
-     INSERT INTO actor.org_unit_proximity (from_org, to_org, prox)
-     SELECT  l.id, r.id, actor.org_unit_proximity(l.id,r.id)
-         FROM  actor.org_unit l, actor.org_unit r
-         WHERE (l.id = NEW.id or r.id = NEW.id);
-
-END IF;
-
-RETURN null;
-
-END;
-$$ LANGUAGE plpgsql;
-
-
-CREATE TRIGGER proximity_update_tgr AFTER INSERT OR UPDATE OR DELETE ON actor.org_unit FOR EACH ROW EXECUTE PROCEDURE actor.org_unit_prox_update ();
-
-COMMIT;