3 #script to move unlinked accounts from one installation to another
4 # source is remote, destination is local
9 use FS::UID qw( adminsuidsetup dbh );
10 use FS::Schema qw( dbdef );
12 use FS::Record qw( qsearchs );
18 #ssh -p 2222 -L 1080:66.209.32.4:7219 -L 5454:localhost:5432 66.209.32.4
20 #my $source_datasrc = 'DBI:Pg:host=66.209.32.4;dbname=freeside;sslmode=require';
21 my $source_datasrc = 'DBI:Pg:host=localhost;port=5454;dbname=freeside';
22 my $source_user = 'readonly';
27 1 => 108, #nothinbut.net
28 3653 => 109, #ewol.com
54 or die "Usage:\n (edit variables at top of script and then)\n".
55 " move-customers user\n";
58 $FS::svc_Common::noexport_hack = 1;
59 $FS::svc_Common::noexport_hack = 1;
63 # source(remote) setup
65 $sdbh = FS::DBI->connect($source_datasrc, $source_user, $source_pw)
66 or die $FS::DBI::errstr;
68 $sdbh->{ChopBlanks} = 1;
72 my $sth = $sdbh->prepare(
73 'select * from svc_acct left join cust_svc using ( svcnum ) where pkgnum is null'
74 ) or die $sdbh->errstr;
76 $sth->execute or die $sth->errstr;
78 while ( my $hashref = $sth->fetchrow_hashref ) {
84 $hash{'domsvc'} = $domsvc_map{ $hash{'domsvc'}};
85 $hash{'svcpart'} = $svcpart_map{$hash{'svcpart'}};
87 my $svc_acct = new FS::svc_acct \%hash;
89 #my $error = $svc_acct->check;
90 my $error = $svc_acct->insert;
94 warn Dumper($svc_acct);