svc_cable service have a single serial / MAC / model, not one-to-many devices like...
[freeside.git] / bin / test_scrub
index 5766925..45a257a 100644 (file)
 #-business-onlinepayment and business-onlinepayment-ach config
 
 use strict;
+use vars qw( $opt_h );
+use Getopt::Std;
 use FS::UID qw(adminsuidsetup dbh);
 use FS::Conf;
+use FS::Schema qw(dbdef);
+
+getopts('h');
 
 adminsuidsetup shift;
 
@@ -37,12 +42,26 @@ my $dsth = dbh->prepare("DELETE FROM cust_main_invoice WHERE dest != 'POST'")
   or die dbh->errstr;
 $dsth->execute or die $dsth->errstr;
 
+my $sth = dbh->prepare("UPDATE part_event SET disabled = 'Y'");
+$sth->execute or die $sth->errstr;
+
 my $conf = new FS::Conf;
 foreach my $item (qw(
   business-onlinepayment
   business-onlinepayment-ach
+  dump-localdest
+  dump-scpdest
+  cust_bill-ftp_spool
+  smtpmachine
 )) {
   $conf->delete($item);
 }
 
+if ($opt_h) {  # not all history can be safely deleted
+  foreach my $table (grep { /^h_\w+$/ } dbdef->tables) {
+    my $sth = dbh->prepare("DELETE FROM $table") or die dbh->errstr;
+    $sth->execute or die $sth->errstr;
+  }
+}
+
 dbh->commit or die dbh->errstr;