foreach my $column ( $new->columns ) {
if ( $self->column($column) ) {
-
warn " $table.$column exists\n" if $DEBUG > 1;
- push @r, $self->column($column)->sql_alter_column( $new->column($column),
- $dbh,
- $opt,
- );
+
+ my ($alter_table, $sql) =
+ $self->column($column)->sql_alter_column( $new->column($column),
+ $dbh,
+ $opt,
+ );
+ push @at, @$alter_table;
+ push @r, @$sql;
} else {
-
warn "column $table.$column does not exist.\n" if $DEBUG > 1;
- push @r, $new->column($column)->sql_add_column( $dbh );
+
+ my ($alter_table, $sql) = $new->column($column)->sql_add_column( $dbh );
+ push @at, @$alter_table;
+ push @r, @$sql;
}
warn "column $table.$column should be dropped.\n" if $DEBUG;
- push @r, $self->column($column)->sql_drop_column( $dbh );
+ push @at, $self->column($column)->sql_drop_column( $dbh );
}
+
+ unshift @r, "ALTER TABLE $table ", join(', ', @at) if @at;
###
# return the statements