order of operations improvement on org removal scripts
authorRogan Hamby <rhamby@equinoxinitiative.org>
Tue, 21 Jul 2020 13:52:33 +0000 (09:52 -0400)
committerRogan Hamby <rhamby@equinoxinitiative.org>
Tue, 21 Jul 2020 13:52:33 +0000 (09:52 -0400)
remove_ou_data/02_remove_patron_extras.sql

index fc715d6..a9f684d 100644 (file)
@@ -55,10 +55,10 @@ DELETE FROM actor.card WHERE usr IN
 UPDATE actor.usr SET card = NULL
 WHERE home_ou IN (SELECT (actor.org_unit_descendants(id)).id from actor.org_unit where shortname = :ou_to_del);
 
-DELETE FROM actor.usr_address 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));
 UPDATE actor.usr SET mailing_address = NULL, billing_address = NULL
 WHERE home_ou IN (SELECT (actor.org_unit_descendants(id)).id from actor.org_unit where shortname = :ou_to_del);
+DELETE FROM actor.usr_address 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.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));