Subject: | Drop table implementation |
The attached patch has a naive implementation for DROP TABLE.
Regards,
Slaven
Subject: | dbix-dbschema-droptable.patch |
Index: DBSchema.pm
===================================================================
--- DBSchema.pm (revision 22520)
+++ DBSchema.pm (working copy)
@@ -289,8 +289,18 @@
}
- # should eventually drop tables not in $new
+ # drop tables not in $new
+ foreach my $table ( $self->tables ) {
+ if ( !$new->table($table) ) {
+
+ warn "table $table should be dropped.\n" if $DEBUG;
+
+ push @r,
+ $self->table($table)->sql_drop_table( $dbh );
+ }
+ }
+
warn join("\n", @r). "\n"
if $DEBUG > 1;
@@ -537,3 +547,7 @@
1;
+# Local Variables:
+# mode: cperl
+# cperl-indent-level: 2
+# End:
Index: DBSchema/Table.pm
===================================================================
--- DBSchema/Table.pm (revision 22520)
+++ DBSchema/Table.pm (working copy)
@@ -697,6 +697,14 @@
}
+sub sql_drop_table {
+ my( $self, $dbh ) = ( shift, _dbh(@_) );
+
+ my $name = $self->name;
+
+ ("DROP TABLE $name");
+}
+
sub _null_sth {
my($dbh, $table) = @_;
my $sth = $dbh->prepare("SELECT * FROM $table WHERE 1=0")