system only reason update routine
[freeside.git] / FS / FS / Upgrade.pm
index b4fc82b..facd6d2 100644 (file)
@@ -82,8 +82,9 @@ sub upgrade_data {
   tie my %hash, 'Tie::IxHash', 
 
     #reason type and reasons
-    'reason_type' => [],
-    'reason'      => [],
+    'reason_type'     => [],
+    'reason'          => [],
+    'cust_pkg_reason' => [],
 
     #need part_pkg before cust_credit...
     'part_pkg' => [],
@@ -103,6 +104,12 @@ sub upgrade_data {
     #remove bad pending records
     'cust_pay_pending' => [],
 
+    #replace invnum and pkgnum with billpkgnum
+    'cust_bill_pkg_detail' => [],
+
+    #usage_classes if we have none
+    'usage_class' => [],
+
   ;
 
   \%hash;
@@ -117,14 +124,18 @@ sub upgrade_sqlradius {
   my @part_export = FS::part_export::sqlradius->all_sqlradius_withaccounting();
 
   foreach my $part_export ( @part_export ) {
+
+    my $errmsg = 'Error adding FreesideStatus to '.
+                 $part_export->option('datasrc'). ': ';
+
     my $dbh = DBI->connect(
       ( map $part_export->option($_), qw ( datasrc username password ) ),
       { PrintError => 0, PrintWarn => 0 }
-    );
+    ) or do {
+      warn $errmsg.$DBI::errstr;
+      next;
+    };
 
-    my $errmsg = 'Error adding FreesideStatus to '.
-                 $part_export->option('datasrc'). ': ';
-  
     my $str2time = str2time_sql( $dbh->{Driver}->{Name} );
     my $group = "UserName";
     $group .= ",Realm"
@@ -141,7 +152,7 @@ sub upgrade_sqlradius {
         $sth_update->execute or die $errmsg.$sth_update->errstr;
       } else {
         my $error = $sth_alter->errstr;
-        warn $errmsg.$error; #unless $error =~ /exists/i;
+        warn $errmsg.$error unless $error =~ /Duplicate column name/i;
       }
     } else {
       my $error = $dbh->errstr;
@@ -154,7 +165,7 @@ sub upgrade_sqlradius {
     if ( $sth_index ) {
       unless ( $sth_index->execute ) {
         my $error = $sth_index->errstr;
-        warn $errmsg.$error; #unless $error =~ /exists/i;
+        warn $errmsg.$error unless $error =~ /Duplicate key name/i;
       }
     } else {
       my $error = $dbh->errstr;