RT# 82137 - default payment amount now has processing fee in total if processing...
[freeside.git] / bin / test_scrub_sql
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 #AND
14 #-masks all payment info
15
16 foreach my $table (qw(
17   part_export_option
18   payment_gateway_option
19   agent_payment_gateway
20   queue_arg
21   queue
22   cust_pay_batch
23 )) {
24   print "DELETE FROM $table;\n";
25   print "DELETE FROM h_$table;\n";
26 }
27
28 # don't break foreign keys in cust_pay_*, just scrub fields that could be
29 # used to access the gateway
30 print "UPDATE payment_gateway SET gateway_module = 'Test', disabled = 'Y', gateway_username = NULL, gateway_password = 'NULL';\n";
31 print "DELETE FROM h_payment_gateway;\n";
32
33 foreach my $table (qw(
34   part_export
35   export_svc
36 )) {
37   print "DELETE FROM $table;\n";
38 }
39
40 print "DELETE FROM cust_main_invoice WHERE dest != 'POST';\n";
41
42 foreach my $item (qw(
43   business-onlinepayment
44   business-onlinepayment-ach
45   smtpmachine
46 )) {
47   print "DELETE FROM conf WHERE name = '$item';\n";
48   print "DELETE FROM h_conf WHERE name = '$item';\n";
49 }
50
51 my @ptables = map { ($_, "h_$_") } qw(
52   cust_main
53   cust_pay
54   cust_pay_pending
55   cust_pay_void
56   cust_refund
57 );
58 foreach my $table (@ptables) {
59   print "UPDATE $table SET payinfo = paymask WHERE payby IN ( 'CARD','DCRD','CHEK','DCHK' );\n";
60 }
61
62 print "UPDATE cust_main set paycvv = NULL;\n";
63 print "UPDATE h_cust_main set paycvv = NULL;\n";