From 13575a1adeaccbf58b86cefcfa70e9a287e9f812 Mon Sep 17 00:00:00 2001 From: Rogan Hamby Date: Mon, 17 Oct 2016 12:25:44 -0400 Subject: [PATCH 1/1] Remove stat cats owned by to be deleted org unit, stat cat entries and entry user mappings by those stat cats or patrons of those org units. --- remove_ou_data/02_remove_patron_extras.sql | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) diff --git a/remove_ou_data/02_remove_patron_extras.sql b/remove_ou_data/02_remove_patron_extras.sql index b993d7b..9524270 100644 --- a/remove_ou_data/02_remove_patron_extras.sql +++ b/remove_ou_data/02_remove_patron_extras.sql @@ -63,6 +63,18 @@ WHERE home_ou IN (SELECT (actor.org_unit_descendants(id)).id from actor.org_unit DELETE FROM actor.usr_message WHERE usr IN (SELECT id FROM actor.usr WHERE home_ou IN (SELECT (actor.org_unit_descendants(id)).id from actor.org_unit where shortname = :ou_to_del)); +DELETE FROM actor.stat_cat_entry_usr_map WHERE target_usr IN +(SELECT id FROM actor.usr WHERE home_ou IN (SELECT (actor.org_unit_descendants(id)).id from actor.org_unit where shortname = :ou_to_del)); + +DELETE FROM actor.stat_cat_entry_usr_map WHERE stat_cat IN +(SELECT id from actor.stat_cat WHERE owner IN (SELECT (actor.org_unit_descendants(id)).id from actor.org_unit where shortname = :ou_to_del)); + +DELETE FROM actor.stat_cat_entry WHERE stat_cat IN +(SELECT id from actor.stat_cat WHERE owner IN (SELECT (actor.org_unit_descendants(id)).id from actor.org_unit where shortname = :ou_to_del)); + +DELETE FROM actor.stat_cat WHERE id IN +(SELECT id from actor.stat_cat WHERE owner IN (SELECT (actor.org_unit_descendants(id)).id from actor.org_unit where shortname = :ou_to_del)); + COMMIT; DROP INDEX actor.tmp_addr_replaces; -- 1.7.2.5