summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorivan <ivan>2009-08-24 07:08:11 +0000
committerivan <ivan>2009-08-24 07:08:11 +0000
commit6859dc3c623542c1a1f823cc6c18c0191527380a (patch)
tree38f5c1b0790be3d5746dd0f9463e9f33ac833498 /bin
parent426211afa7e8c85bde1473f53e15d166df60461a (diff)
(start of) customer move script, RT#5351
Diffstat (limited to 'bin')
-rwxr-xr-xbin/move-customers23
1 files changed, 21 insertions, 2 deletions
diff --git a/bin/move-customers b/bin/move-customers
index 1da39b8..f1abfb5 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 ) = @_;