71513: Card tokenization [upgrade implemented]
[freeside.git] / bin / wipe-customers
1 #!/usr/bin/perl
2
3 use strict;
4 use FS::UID qw(adminsuidsetup);
5 use FS::Record qw(qsearch);
6 use FS::cust_main;
7
8 die "this removes all customers in your database except for customer 1 - remove this line to enable";
9
10 my $user = shift or die "usage: wipe-customers username\n";
11 adminsuidsetup $user;
12
13 #this isn't terribly efficient, but the idea was clearing out a test database,
14 #not actually destroying a large amount of data
15
16 foreach my $cust_main (
17
18   qsearch('cust_main', { 'custnum' => { op=>'!=', value=>'1' } } )
19
20 ) {
21
22   my @cerrors = $cust_main->cancel( quiet=>1, nobill=>1 );
23   if ( @cerrors ) {
24     die join(' / ', @cerrors);
25   }
26
27   my $error = $cust_main->delete( 'delete_financials' => 1);
28   die $error if $error;
29
30 }