From b333223b0223e560a877e1d5f4c433b5ef6da54f Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 21 Dec 2008 21:39:55 +0000 Subject: unique checking for svc_phone like svc_acct, closes: RT#4204 (also a few lines of the new per-agent config snuck in Conf.pm from RT#3989) --- FS/bin/freeside-upgrade | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'FS/bin/freeside-upgrade') diff --git a/FS/bin/freeside-upgrade b/FS/bin/freeside-upgrade index f3c446169..0b5758d8e 100755 --- a/FS/bin/freeside-upgrade +++ b/FS/bin/freeside-upgrade @@ -77,21 +77,26 @@ print "\n" if $DRY_RUN; if ( $dbh->{Driver}->{Name} =~ /^mysql/i && ! $opt_s ) { - my $sth = $dbh->prepare( - "SELECT COUNT(*) FROM duplicate_lock WHERE lockname = 'svc_acct'" - ) or die $dbh->errstr; + foreach my $table (qw( svc_acct svc_phone )) { - $sth->execute or die $sth->errstr; - - unless ( $sth->fetchrow_arrayref->[0] ) { - - $sth = $dbh->prepare( - "INSERT INTO duplicate_lock ( lockname ) VALUES ( 'svc_acct' )" + my $sth = $dbh->prepare( + "SELECT COUNT(*) FROM duplicate_lock WHERE lockname = '$table'" ) or die $dbh->errstr; $sth->execute or die $sth->errstr; + unless ( $sth->fetchrow_arrayref->[0] ) { + + $sth = $dbh->prepare( + "INSERT INTO duplicate_lock ( lockname ) VALUES ( '$table' )" + ) or die $dbh->errstr; + + $sth->execute or die $sth->errstr; + + } + } + } $dbh->commit or die $dbh->errstr; -- cgit v1.2.1