should really fix bug commiting between each table upgrade, arg, RT#8580
[freeside.git] / FS / bin / freeside-upgrade
index 97c704c..a0a5fe6 100755 (executable)
@@ -4,7 +4,7 @@ use strict;
 use vars qw($opt_d $opt_s $opt_q $opt_v $opt_r);
 use vars qw($DEBUG $DRY_RUN);
 use Getopt::Std;
-use DBIx::DBSchema 0.31;
+use DBIx::DBSchema 0.31; #0.39
 use FS::UID qw(adminsuidsetup checkeuid datasrc driver_name);  #getsecrets);
 use FS::CurrentUser;
 use FS::Schema qw( dbdef dbdef_dist reload_dbdef );
@@ -30,6 +30,11 @@ $FS::UID::callback_hack = 1;
 my $dbh = adminsuidsetup($user);
 $FS::UID::callback_hack = 0;
 
+if ( driver_name =~ /^mysql/i ) { #until 0.39 is required above
+  eval "use DBIx::DBSchema 0.39;";
+  die $@ if $@;
+}
+
 #needs to match FS::Schema...
 my $dbdef_file = "%%%FREESIDE_CONF%%%/dbdef.". datasrc;
 
@@ -158,6 +163,8 @@ unless ( $DRY_RUN || $opt_s ) {
 $dbh->commit or die $dbh->errstr;
 $dbh->disconnect or die $dbh->errstr;
 
+$FS::UID::AutoCommit = 1;
+
 $dbh = adminsuidsetup($user);
 
 warn "Re-initialization with updated schema completed in ". (time-$start). " seconds\n"; # if $DEBUG;