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
6 die "remove this line to run -- NEVER ON A LIVE DATABASE";
8 #-all exports (all records in part_export, part_export_option export_svc)
9 #-all non-POST invoice destinations (cust_main_invoice)
10 #-all payment gateways and agent payment gw overrides (payment_gateway,
11 # payment_gateway_option, agent_payment_gateway)
12 #-everything in the job queue (queue and queue_arg)
13 #-business-onlinepayment and business-onlinepayment-ach config
16 use vars qw( $opt_h );
18 use FS::UID qw(adminsuidsetup dbh);
20 use FS::Schema qw(dbdef);
27 # payment_gateway_option
28 # agent_payment_gateway
29 foreach my $table (qw(
37 my $sth = dbh->prepare("DELETE FROM $table") or die dbh->errstr;
38 $sth->execute or die $sth->errstr;
42 my $dsth = dbh->prepare("DELETE FROM cust_main_invoice WHERE dest != 'POST'")
44 $dsth->execute or die $dsth->errstr;
46 foreach my $table (qw( cust_main cust_payby
47 cust_pay_pending cust_pay cust_pay_void cust_pay_batch
50 my $ccsth = dbh->prepare("
51 UPDATE $table SET payinfo = '4111111111111111'
52 WHERE payby = 'CARD' OR payby = 'DCRD'
53 ") or die dbh->errstr;
54 $ccsth->execute or die $ccsth->errstr;
57 my $sth = dbh->prepare("UPDATE part_event SET disabled = 'Y'");
58 $sth->execute or die $sth->errstr;
60 my $conf = new FS::Conf;
62 business-onlinepayment
63 business-onlinepayment-ach
72 if ($opt_h) { # not all history can be safely deleted
73 foreach my $table (grep { /^h_\w+$/ } dbdef->tables) {
74 my $sth = dbh->prepare("DELETE FROM $table") or die dbh->errstr;
75 $sth->execute or die $sth->errstr;
79 dbh->commit or die dbh->errstr;