- Update Column.pm, move all mysql and Pg-specific code to DBD driver
callbacks
- Update Table.pm, add local_options
+ - Fix mysql NULL reverse-engineering and updating code
0.34 Sun Aug 19 10:08:51 PDT 2007
- More work on update schema from Slaven Rezic <srezic@cpan.org>,
This module implements a MySQL-native driver for DBIx::DBSchema.
=cut
+ use Data::Dumper;
sub columns {
my($proto, $dbh, $table ) = @_;
my $sth = $dbh->prepare("SHOW COLUMNS FROM $table") or die $dbh->errstr;
$sth->execute or die $sth->errstr;
my @r = map {
+ #warn Dumper($_);
$_->{'Type'} =~ /^(\w+)\(?([^)]+)?\)?( \d+)?$/
or die "Illegal type: ". $_->{'Type'}. "\n";
my($type, $length) = ($1, $2);
[
$_->{'Field'},
$type,
- $_->{'Null'},
+ ( $_->{'Null'} =~ /^YES$/i ? 'NULL' : '' ),
$length,
$_->{'Default'},
$_->{'Extra'}
}
+sub alter_column_callback {
+ my( $proto, $dbh, $table, $old_column, $new_column ) = @_;
+ my $old_name = $old_column->name;
+ my $new_def = $new_column->line($dbh);
+
+# this would have been nice, but it appears to be doing too much...
+
+# return {} if $old_column->line($dbh) eq $new_column->line($dbh);
+#
+# #{ 'sql_alter' =>
+# { 'sql_alter_null' =>
+# "ALTER TABLE $table CHANGE $old_name $new_def",
+# };
+
+ return {} if $old_column->null eq $new_column->null;
+ { 'sql_alter_null' =>
+ "ALTER TABLE $table MODIFY $new_def",
+ };
+
+
+}
+
=head1 AUTHOR
Ivan Kohler <ivan-dbix-dbschema@420.am>