From 6859dc3c623542c1a1f823cc6c18c0191527380a Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 24 Aug 2009 07:08:11 +0000 Subject: [PATCH] (start of) customer move script, RT#5351 --- bin/move-customers | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/bin/move-customers b/bin/move-customers index 1da39b89e..f1abfb522 100755 --- a/bin/move-customers +++ b/bin/move-customers @@ -17,6 +17,7 @@ use FS::part_svc; use FS::cust_bill_ApplicationCommon; my $DANGEROUS = 1; +my $DRY = 1; #ssh -p 2222 -L 1080:66.209.32.4:7219 -L 5454:localhost:5432 66.209.32.4 @@ -46,6 +47,8 @@ adminsuidsetup $user; $sdbh = DBI->connect($source_datasrc, $source_user, $source_pw) or die $DBI::errstr; +$sdbh->{ChopBlanks} = 1; + import_table('pkg_class', 'nomap' => 1); my $agent_sth = $sdbh->prepare( @@ -145,8 +148,8 @@ while ( my $agentrow = $agent_sth->fetchrow_hashref ) { 'agent_custid' => $src_custnum, }; - $cust_main->ship_country('') if $cust_main->ship_country eq ' '; - $cust_main->tax('') if $cust_main->tax =~ /^\s+$/; + #$cust_main->ship_country('') if $cust_main->ship_country eq ' '; + #$cust_main->tax('') if $cust_main->tax =~ /^\s+$/; my $error = $cust_main->insert; if ( $error ) { @@ -248,6 +251,10 @@ while ( my $agentrow = $agent_sth->fetchrow_hashref ) { if $src_classnum; my $part_pkg = new FS::part_pkg $hashref; + + #$part_pkg->setuptax('') if $part_pkg->setuptax =~ /^\s+$/; + #$part_pkg->recurtax('') if $part_pkg->recurtax =~ /^\s+$/; + my $error = $part_pkg->insert( 'options' => {} ); die "*** FATAL: error importing part_pkg src pkgpart $src_pkgpart ". ": $error" @@ -434,6 +441,18 @@ while ( my $agentrow = $agent_sth->fetchrow_hashref ) { } + +warn "import successful!\n" +if ( $DRY ) { + warn "rolling back (dry run)\n"; + dbh->rollback or die dbh->errstr; + warn "rolled back\n" +} else { + warn "commiting\n"; + dbh->commit or die dbh->errstr; + warn "committed\n"; +} + sub import_table { my( $table, %opt ) = @_; -- 2.11.0