X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2Fbin%2Ffreeside-upgrade;h=a0a5fe68cacffc482c4eb0de6a4b09cf452a9810;hb=55375c203e5d337e232041e368869a6336f1fd26;hp=49f1df8462b77bd62aae19c1e43685edae5a0c1b;hpb=c27c62c2fe1c79811f389cc0d17c330157888d01;p=freeside.git diff --git a/FS/bin/freeside-upgrade b/FS/bin/freeside-upgrade index 49f1df846..a0a5fe68c 100755 --- a/FS/bin/freeside-upgrade +++ b/FS/bin/freeside-upgrade @@ -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; @@ -60,9 +65,14 @@ if (dbdef->table('cust_main')->column('agent_custid') && ! $opt_s) { #from 1.3 to 1.4... if not, it needs to be hooked into -upgrade here or #you'll lose all the part_svc settings it migrates to part_svc_column -my @statements = +my @statements = dbdef->sql_update_schema( dbdef_dist(datasrc), + $dbh, + { 'nullify_default' => 1, }, + ); + +@statements = grep { $_ !~ /^CREATE +INDEX +h_queue/i } #useless, holds up queue insertion - dbdef->sql_update_schema( dbdef_dist(datasrc), $dbh ); + @statements; unless ( driver_name =~ /^mysql/i ) { #not necessary under non-mysql, takes forever on big db @@ -153,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;