Commit 27ab8ff2 authored by Francesc Guasch's avatar Francesc Guasch
Browse files

fix(upgrade): change field size on upgrade

issue #1073
parent 5a9f4bf7
......@@ -1053,9 +1053,21 @@ sub _upgrade_table {
my ($table, $field, $definition) = @_;
my $dbh = $CONNECTOR->dbh;
my ($new_size) = $definition =~ m{\((\d+)};
my $sth = $dbh->column_info(undef,undef,$table,$field);
my $row = $sth->fetchrow_hashref;
$sth->finish;
if ( $dbh->{Driver}{Name} =~ /mysql/
&& $row && $row->{COLUMN_SIZE}
&& $new_size
&& $new_size != $row->{COLUMN_SIZE}) {
$dbh->do("alter table $table change $field $field $definition");
warn "INFO: changing $field $row->{COLUMN_SIZE} to $new_size in $table\n" if $0 !~ /\.t$/;
return;
}
return if $row;
warn "INFO: adding $field $definition to $table\n" if $0 !~ /\.t$/;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment