+sub column_callback {
+ my( $proto, $dbh, $table, $column_obj ) = @_;
+
+ my $hashref = { 'explicit_null' => 1, };
+
+ $hashref->{'effective_local'} = 'AUTO_INCREMENT'
+ if $column_obj->type =~ /^(\w*)SERIAL$/i;
+
+ if ( $column_obj->quoted_default =~ /^(NOW)\(\)$/i
+ && $column_obj->type =~ /^(TIMESTAMP|DATETIME)$/i ) {
+
+ $hashref->{'effective_default'} = 'CURRENT_TIMESTAMP';
+ $hashref->{'effective_type'} = 'TIMESTAMP';
+
+ }
+
+ $hashref;
+
+}
+
+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);
+
+ my $hashref = {};
+
+ my %canonical = (
+ 'INTEGER' => 'INT',
+ 'SERIAL' => 'INT',
+ 'BIGSERIAL' => 'BIGINT',
+ 'REAL' => 'DOUBLE', #'FLOAT',
+ 'DOUBLE PRECISION' => 'DOUBLE',
+ );
+ foreach ($old_column, $new_column) {
+ $_->type($canonical{uc($_->type)}) if $canonical{uc($_->type)};
+ }
+
+ my %canonical_length = (
+ 'INT' => 11,
+ 'BIGINT' => 20,
+ 'DECIMAL' => '10,0',
+ );
+ $new_column->length( $canonical_length{uc($new_column->type)} )
+ if $canonical_length{uc($new_column->type)}
+ && ($new_column->length||'') eq '';
+
+ #change type/length
+ if ( uc($old_column->type) ne uc($new_column->type)
+ || ($old_column->length||'') ne ($new_column->length||'')
+ )
+ {
+ my $old_def = $old_column->line($dbh);
+ $hashref->{'sql_alter_type'} =
+ "CHANGE $old_name $new_def";
+ }
+
+ #change nullability
+ if ( $old_column->null ne $new_column->null ) {
+ $hashref->{'sql_alter_null'} =
+ "ALTER TABLE $table MODIFY $new_def";
+ }
+
+ $hashref;
+}
+