- if ( $sth_alter && $sth_alter->execute ) {
- my $sth_update = $dbh->prepare(
- "UPDATE radacct SET FreesideStatus = 'done' WHERE FreesideStatus IS NULL"
- ) or die $dbh->errstr;
- $sth_update->execute or die $sth_update->errstr;
+ if ( $sth_alter ) {
+ if ( $sth_alter->execute ) {
+ my $sth_update = $dbh->prepare(
+ "UPDATE radacct SET FreesideStatus = 'done' WHERE FreesideStatus IS NULL"
+ ) or die $errmsg.$dbh->errstr;
+ $sth_update->execute or die $errmsg.$sth_update->errstr;
+ } else {
+ my $error = $sth_alter->errstr;
+ warn $errmsg.$error unless $error =~ /Duplicate column name/i;
+ }
+ } else {
+ my $error = $dbh->errstr;
+ warn $errmsg.$error; #unless $error =~ /exists/i;
+ }
+
+ my $sth_index = $dbh->prepare(
+ "CREATE INDEX FreesideStatus ON radacct ( FreesideStatus )"
+ );
+ if ( $sth_index ) {
+ unless ( $sth_index->execute ) {
+ my $error = $sth_index->errstr;
+ warn $errmsg.$error unless $error =~ /Duplicate key name/i;
+ }
+ } else {
+ my $error = $dbh->errstr;
+ warn $errmsg.$error; #unless $error =~ /exists/i;