- More work on update schema from Slaven Rezic <srezic@cpan.org>,
thanks!
+ implement table dropping (closes: CPAN#27936)
+ + implement column dropping (closes: CPAN#27896)
- Fix to quiet warnings from internal use of old API from Jesse Vincent
<jesse+cpan@fsck.com>, thanks! (closes: CPAN#27958)
- Make table dropping optional, not the default.
use DBIx::DBSchema::ColGroup::Unique;
use DBIx::DBSchema::ColGroup::Index;
-$VERSION = "0.34_02";
+$VERSION = "0.34_03";
$VERSION = eval $VERSION; # modperlstyle: convert the string into a number
$DEBUG = 0;
Daniel Hanks <hanksdc@about-inc.com> contributed the Oracle driver.
-Jesse Vincent contributed the SQLite driver.
+Jesse Vincent contributed the SQLite driver and fixes to quiet down
+internal usage of the old API.
+
+Slaven Rezic <srezic@cpan.org> contributed column and table dropping, Pg
+bugfixes and more.
=head1 CONTRIBUTIONS
@r;
}
+=item sql_drop_column [ DBH ]
+
+Returns a list of SQL statements to drop this column from an existing table.
+
+The optional database handle or DBI data source/username/password is not yet
+used.
+
+=cut
+
+sub sql_drop_column {
+ my( $self, $dbh ) = ( shift, _dbh(@_) );
+
+ my $table = $self->table_name;
+ my $name = $self->name;
+
+ ("ALTER TABLE $table DROP COLUMN $name"); # XXX what about indexes???
+}
=back
my $tempnum = 1;
###
- # columns
+ # columns (add/alter)
###
foreach my $column ( $new->columns ) {
warn "creating new index $table.$new\n" if $DEBUG > 1;
push @r, $new_indices{$new}->sql_create_index($table);
}
+
+ ###
+ # columns (drop)
+ ###
+
+ foreach my $column ( grep !$new->column($_), $self->columns ) {
+
+ warn "column $table.$column should be dropped.\n" if $DEBUG;
+
+ push @r, $self->column($column)->sql_drop_column( $dbh );
+
+ }
###
# return the statements