summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjeff <jeff>2007-08-21 23:52:08 +0000
committerjeff <jeff>2007-08-21 23:52:08 +0000
commit2a3f680a86496c651f63574ead22b454d4ce0830 (patch)
tree3581ca9d09159d18f34460a94205986ec5ccc7ef
parentbc99c91d9aa0ed5e7f32da57d9238051e401d13b (diff)
agent_custid bugfix (1746) (backport)
-rwxr-xr-xFS/bin/freeside-upgrade19
1 files changed, 18 insertions, 1 deletions
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 );
}