start of distinct acq removal file
authorRogan Hamby <rhamby@esilibrary.com>
Fri, 9 Feb 2018 13:44:59 +0000 (08:44 -0500)
committerRogan Hamby <rhamby@esilibrary.com>
Fri, 9 Feb 2018 13:44:59 +0000 (08:44 -0500)
remove_ou_data/16_remove_acq.sql [copied from remove_ou_data/16_delete_usrs_stage_3.sql with 71% similarity]
remove_ou_data/17_delete_usrs_stage_1.sql [moved from remove_ou_data/16_delete_usrs_stage_1.sql with 97% similarity]
remove_ou_data/17_delete_usrs_stage_3.sql [moved from remove_ou_data/16_delete_usrs_stage_3.sql with 100% similarity]
remove_ou_data/18_vauum_analyze.sql [moved from remove_ou_data/17_vacuum_analyze.sql with 100% similarity]

similarity index 71%
copy from remove_ou_data/16_delete_usrs_stage_3.sql
copy to remove_ou_data/16_remove_acq.sql
index 09cc9d2..d88d1b7 100644 (file)
 \set ECHO all
 \timing
 
-SELECT id
-FROM actor.usr WHERE home_ou IN (
-    SELECT (actor.org_unit_descendants(id)).id FROM actor.org_unit
-    WHERE shortname IN (SELECT shortname FROM esi.ous_to_del)
+BEGIN;
+
+DELETE FROM acq.lineitem WHERE picklist IN (SELECT id FROM acq.picklist WHERE org_unit IN 
+    (SELECT (actor.org_unit_descendants(id)).id from actor.org_unit where shortname = :ou_to_del)
 );
 
+DELETE FROM acq.picklist WHERE org_unit IN (SELECT (actor.org_unit_descendants(id)).id from actor.org_unit where shortname = :ou_to_del); 
 
--- find the problems and clear them up
+COMMIT;
similarity index 97%
rename from remove_ou_data/16_delete_usrs_stage_1.sql
rename to remove_ou_data/17_delete_usrs_stage_1.sql
index 78c3956..25e36ff 100644 (file)
@@ -25,7 +25,7 @@
 
 \t
 \psql format unaligned
-\o 16_delete_usrs_stage_2.sql
+\o 17_delete_usrs_stage_2.sql
 
 SELECT 'ALTER TABLE actor.usr DISABLE RULE protect_user_delete;';
 SELECT 'DELETE FROM actor.usr WHERE id = ' || id || ';'