3 use FS::UID qw(adminsuidsetup);
5 my( $olddb, $newdb ) = ( shift, shift );
7 $FS::CurrentUser::upgrade_hack = 1;
8 my $dbh = adminsuidsetup;
10 my $statement = "select * from links where base like 'fsck.com-rt://$olddb/%' OR target like 'fsck.com-rt://$olddb/%'";
12 my $sth = $dbh->prepare($statement) or die $dbh->errstr;
13 $sth->execute or die $sth->errstr;
15 while ( my $row = $sth->fetchrow_hashref ) {
17 ( my $base = $row->{'base'} )
18 =~ s(^fsck\.com-rt://$olddb/)(fsck.com-rt://$newdb/);
20 ( my $target = $row->{'target'} )
21 =~ s(^fsck\.com-rt://$olddb/)(fsck.com-rt://$newdb/);
23 if ( $row->{'base'} ne $base || $row->{'target'} ne $target ) {
25 my $update = 'UPDATE links SET base = ?, target = ? where id = ?';
26 my @param = ( $base, $target, $row->{'id'} );
28 warn "$update : ". join(', ', @param). "\n";
29 $dbh->do($update, {}, @param );