1 -- Copyright 2015, Equinox Software, Inc.
2 -- Author: Galen Charlton <gmc@esilibrary.com>
4 -- This program is free software; you can redistribute it and/or
5 -- modify it under the terms of the GNU General Public License
6 -- as published by the Free Software Foundation; either version 2
7 -- of the License, or (at your option) any later version.
9 -- This program is distributed in the hope that it will be useful,
10 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 -- GNU General Public License for more details.
14 -- You should have received a copy of the GNU General Public License
15 -- along with this program; if not, write to the Free Software
16 -- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 \set ou_to_del ''''EXAMPLE''''
22 create index tmp_idx on money.billing(btype);
23 ALTER TABLE action.circulation DISABLE TRIGGER action_circulation_target_copy_trig;
24 ALTER TABLE asset.copy_location DISABLE RULE protect_copy_location_delete;
28 DELETE FROM actor.org_address WHERE org_unit IN
29 (SELECT (actor.org_unit_descendants(id)).id from actor.org_unit where shortname = :ou_to_del);
31 UPDATE actor.org_unit SET ill_address = NULL, holds_address = NULL, mailing_address = NULL, billing_address = NULL
33 (SELECT (actor.org_unit_descendants(id)).id from actor.org_unit where shortname = :ou_to_del);
35 UPDATE action.circulation SET copy_location = 1
36 WHERE copy_location IN (SELECT id FROM asset.copy_location WHERE owning_lib IN
37 (SELECT (actor.org_unit_descendants(id)).id from actor.org_unit where shortname = :ou_to_del));
38 DELETE FROM asset.copy_location WHERE owning_lib IN
39 (SELECT (actor.org_unit_descendants(id)).id from actor.org_unit where shortname = :ou_to_del);
41 DELETE FROM money.billing
43 SELECT id FROM config.billing_type
45 (SELECT (actor.org_unit_descendants(id)).id from actor.org_unit where shortname = :ou_to_del)
48 DELETE FROM action_trigger.event
50 SELECT id FROM action_trigger.event_definition
52 (SELECT (actor.org_unit_descendants(id)).id from actor.org_unit where shortname = :ou_to_del)
54 DELETE FROM action_trigger.environment
56 SELECT id FROM action_trigger.event_definition
58 (SELECT (actor.org_unit_descendants(id)).id from actor.org_unit where shortname = :ou_to_del)
60 DELETE FROM action_trigger.event_params
62 SELECT id FROM action_trigger.event_definition
64 (SELECT (actor.org_unit_descendants(id)).id from actor.org_unit where shortname = :ou_to_del)
66 DELETE FROM action_trigger.event_definition
68 (SELECT (actor.org_unit_descendants(id)).id from actor.org_unit where shortname = :ou_to_del);
71 DROP INDEX money.tmp_idx;
72 ALTER TABLE asset.copy_location ENABLE RULE protect_copy_location_delete;
73 ALTER TABLE action.circulation ENABLE TRIGGER action_circulation_target_copy_trig;