enable mpm_prefork, deb 9+
[freeside.git] / bin / wipe-payment_history
1 #!/usr/bin/perl
2
3 use FS::Record;
4 use FS::UID qw( adminsuidsetup dbh );
5
6 adminsuidsetup shift;
7
8 foreach $table (qw(
9
10   cust_bill
11    cust_bill_pkg
12     cust_bill_pkg_detail
13     cust_bill_pkg_display
14     cust_bill_pkg_fee
15     cust_bill_pkg_tax_location
16     cust_bill_pkg_tax_rate_location
17     cust_bill_pkg_discount
18
19   cust_bill_void
20     cust_bill_pkg_void
21     cust_bill_pkg_detail_void
22     cust_bill_pkg_display_void
23     cust_bill_pkg_fee_void
24     cust_bill_pkg_tax_location_void
25     cust_bill_pkg_tax_rate_location_void
26     cust_bill_pkg_discount_void
27
28   cust_statement
29
30   cust_pay
31     cust_bill_pay
32     cust_bill_pay_batch
33     cust_bill_pay_pkg
34     cust_pay_refund
35
36   cust_pay_void
37     cust_bill_pay
38
39   cust_credit
40     cust_credit_bill
41     cust_credit_bill_pkg
42     cust_credit_source_bill_pkg
43
44   cust_credit_void
45
46   cust_refund
47     cust_credit_refund
48
49   cust_pay_pending
50
51   pay_batch
52   cust_pay_batch
53
54   bill_batch
55   cust_bill_batch
56   cust_bill_batch_option
57
58   cust_tax_exempt_pkg
59   cust_tax_exempt_pkg_void
60
61 )) {
62   foreach $t ( $table, "h_$table" ) {
63     my $sql = "DELETE FROM $t";
64     print "$sql;\n"; #dbh->do($sql);
65   }
66 }
67
68 foreach my $e ( 'cust_event', 'h_cust_event' ) {
69   my $sql = "DELETE FROM cust_event WHERE 'cust_bill' = ( SELECT eventtable FROM part_event WHERE part_event.eventpart = cust_event.eventpart )"; # and not exists ( select 1 from cust_bill where cust_event.tablenum = cust_bill.invnum )";
70   print "$sql;\n"; #dbh->do($sql);
71 }
72
73 #cust_event_fee???
74
75 1;