summaryrefslogtreecommitdiff
path: root/bin/test_scrub_sql
blob: 30ee1d277d6500c7fd4f3b574a37cf3b406432db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/perl -w

#This drops anything from the database that could cause live things to happen.
#You'd want to do this on a test copy of your live database but NEVER on the
#live database itself.

#-all exports (all records in part_export, part_export_option export_svc)
#-all non-POST invoice destinations (cust_main_invoice)
#-all payment gateways and agent payment gw overrides (payment_gateway,
# payment_gateway_option, agent_payment_gateway)
#-everything in the job queue (queue and queue_arg)
#-business-onlinepayment and business-onlinepayment-ach config
#AND
#-masks all payment info

foreach my $table (qw(
  part_export_option
  payment_gateway_option
  agent_payment_gateway
  queue_arg
  queue
  cust_pay_batch
)) {
  print "DELETE FROM $table;\n";
  print "DELETE FROM h_$table;\n";
}

# don't break foreign keys in cust_pay_*, just scrub fields that could be
# used to access the gateway
print "UPDATE payment_gateway SET gateway_module = 'Test', disabled = 'Y', gateway_username = NULL, gateway_password = 'NULL';\n";
print "DELETE FROM h_payment_gateway;\n";

foreach my $table (qw(
  part_export
  export_svc
)) {
  print "DELETE FROM $table;\n";
}

print "DELETE FROM cust_main_invoice WHERE dest != 'POST';\n";

foreach my $item (qw(
  business-onlinepayment
  business-onlinepayment-ach
  smtpmachine
)) {
  print "DELETE FROM conf WHERE name = '$item';\n";
  print "DELETE FROM h_conf WHERE name = '$item';\n";
}

my @ptables = map { ($_, "h_$_") } qw(
  cust_main
  cust_pay
  cust_pay_pending
  cust_pay_void
  cust_refund
);
foreach my $table (@ptables) {
  print "UPDATE $table SET payinfo = paymask WHERE payby IN ( 'CARD','DCRD','CHEK','DCHK' );\n";
}

print "UPDATE cust_main set paycvv = NULL;\n";
print "UPDATE h_cust_main set paycvv = NULL;\n";