adding scrub tool
[freeside.git] / bin / test_scrub
1 #!/usr/bin/perl -w
2
3 #This drops anything from the database that could cause live things to happen.
4 #You'd want to do this on a test copy of your live database but NEVER on the
5 #live database itself.
6
7 #-all exports (all records in part_export, part_export_option export_svc)
8 #-all non-POST invoice destinations (cust_main_invoice)
9 #-all payment gateways and agent payment gw overrides (payment_gateway,
10 # payment_gateway_option, agent_payment_gateway)
11 #-everything in the job queue (queue and queue_arg)
12 #-business-onlinepayment and business-onlinepayment-ach config
13
14 use strict;
15 use FS::UID qw(adminsuidsetup dbh);
16 use FS::Conf;
17
18 adminsuidsetup shift;
19
20 foreach my $table (qw(
21   part_export
22   part_export_option
23   export_svc
24   payment_gateway
25   payment_gateway_option
26   agent_payment_gateway
27   queue
28   queue_arg
29 )) {
30
31   my $sth = dbh->prepare("DELETE FROM $table") or die dbh->errstr;
32   $sth->execute or die $sth->errstr;
33
34 }
35
36 my $dsth = dbh->prepare("DELETE FROM cust_main_invoice WHERE dest != 'POST'")
37   or die dbh->errstr;
38 $dsth->execute or die $dsth->errstr;
39
40 my $conf = new FS::Conf;
41 foreach my $item (qw(
42   business-onlinepayment
43   business-onlinepayment-ach
44 )) {
45   $conf->delete($item);
46 }
47
48 dbh->commit or die dbh->errstr;