my $table = $self->name;
+ my @at = ();
my @r = ();
my @r_later = ();
my $tempnum = 1;
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
Copyright (c) 2000-2007 Ivan Kohler
Copyright (c) 2000 Mail Abuse Prevention System LLC
-Copyright (c) 2007-2010 Freeside Internet Services, Inc.
+Copyright (c) 2007-2013 Freeside Internet Services, Inc.
All rights reserved.
This program is free software; you can redistribute it and/or modify it under
the same terms as Perl itself.