From: jeff Date: Tue, 21 Aug 2007 23:52:08 +0000 (+0000) Subject: agent_custid bugfix (1746) (backport) X-Git-Tag: freeside_1_7_3rc1~346 X-Git-Url: http://git.freeside.biz/gitweb/?a=commitdiff_plain;h=2a3f680a86496c651f63574ead22b454d4ce0830;p=freeside.git agent_custid bugfix (1746) (backport) --- diff --git a/FS/bin/freeside-upgrade b/FS/bin/freeside-upgrade index b2943524b..792b8ba13 100755 --- a/FS/bin/freeside-upgrade +++ b/FS/bin/freeside-upgrade @@ -34,10 +34,27 @@ reload_dbdef($dbdef_file); $DBIx::DBSchema::DEBUG = $DEBUG; $DBIx::DBSchema::Table::DEBUG = $DEBUG; +my @bugfix = (); + +if (dbdef->table('cust_main')->column('agent_custid')) { + push @bugfix, + "UPDATE cust_main SET agent_custid = NULL where agent_custid = ''"; + + push @bugfix, + "UPDATE h_cust_main SET agent_custid = NULL where agent_custid = ''" + if (dbdef->table('h_cust_main')); +} + if ( $DRY_RUN ) { - print join(";\n", dbdef->sql_update_schema( dbdef_dist, $dbh ) ). ";\n"; + print + join(";\n", @bugfix, dbdef->sql_update_schema( dbdef_dist, $dbh ) ). ";\n"; exit; } else { + foreach my $statement ( @bugfix ) { + $dbh->do( $statement ) + or die "Error: ". $dbh->errstr. "\n executing: $statement"; + } + dbdef->update_schema( dbdef_dist, $dbh ); }