From 66a5ec18848e64e83bdf7e1bd3ff84bc696a1845 Mon Sep 17 00:00:00 2001 From: Ben Ostrowsky Date: Thu, 23 Jun 2011 17:10:17 +0000 Subject: [PATCH 1/1] Utilities to nuke data --- sql/nuke-bibs-and-items.sql | 26 ++++++++++++++++++++++++++ sql/nuke-patrons-and-circs.sql | 20 ++++++++++++++++++++ 2 files changed, 46 insertions(+), 0 deletions(-) create mode 100644 sql/nuke-bibs-and-items.sql create mode 100644 sql/nuke-patrons-and-circs.sql diff --git a/sql/nuke-bibs-and-items.sql b/sql/nuke-bibs-and-items.sql new file mode 100644 index 0000000..f88bf93 --- /dev/null +++ b/sql/nuke-bibs-and-items.sql @@ -0,0 +1,26 @@ +BEGIN; + +DROP TABLE IF EXISTS asset.call_number_temp; +CREATE TABLE asset.call_number_temp AS ( + SELECT * FROM asset.call_number WHERE id = -1 +); + +DROP TABLE IF EXISTS biblio.record_entry_temp; +CREATE TABLE biblio.record_entry_temp AS ( + SELECT * FROM biblio.record_entry WHERE id = -1 +); + + +TRUNCATE + action.circulation, + asset.copy, + biblio.record_entry, + asset.call_number, + metabib.metarecord_source_map, + metabib.metarecord +CASCADE; + +INSERT INTO asset.call_number SELECT * FROM asset.call_number_temp; +INSERT INTO biblio.record_entry SELECT * FROM biblio.record_entry_temp; + + diff --git a/sql/nuke-patrons-and-circs.sql b/sql/nuke-patrons-and-circs.sql new file mode 100644 index 0000000..4b7c47f --- /dev/null +++ b/sql/nuke-patrons-and-circs.sql @@ -0,0 +1,20 @@ +alter table actor.usr disable rule protect_user_delete; +begin; +delete from actor.usr where usrname !~ 'admin'; +delete from actor.usr_note where usr not in (select id from actor.usr); +delete from actor.usr_address where usr not in (select id from actor.usr); +delete from actor.card where usr not in (select id from actor.usr); +delete from action.circulation; +delete from action.hold_request; +delete from money.billing; +delete from money.grocery; +delete from action.non_cataloged_circulation; +delete from action.in_house_use; +delete from reporter.template_folder where owner not in (select id from actor.usr); +delete from reporter.report_folder where owner not in (select id from actor.usr); +delete from reporter.output_folder where owner not in (select id from actor.usr); +delete from reporter.template where owner not in (select id from actor.usr); +delete from reporter.report where owner not in (select id from actor.usr); +delete from reporter.schedule where runner not in (select id from actor.usr); +commit; +alter table actor.usr enable rule protect_user_delete; -- 1.7.2.5