( $_[1]->comments ? ('-- ' . $_[1]->comments . "\n ") : () )
}
+sub table_comments {
+ my ($self, $table) = @_;
+ if ($self->add_comments) {
+ return (
+ "\n",
+ "--\n",
+ "-- Table: " . $self->quote($table->name) . "\n",
+ "--\n",
+ map "-- $_\n", $table->comments
+ )
+ } else {
+ return ()
+ }
+}
+
sub field_nullable { ($_[1]->is_nullable ? $_[0]->nullable : 'NOT NULL' ) }
sub field_default {
my $add_drop_table = $translator->add_drop_table;
my $schema = $translator->schema;
- my $output = $future->header_comments;
- $output .= $future->drop_tables($schema);
+ my $output = $future->header_comments
+ . $future->drop_tables($schema);
my @foreign_constraints = ();
for my $table ( grep { $_->name } $schema->get_tables ) {
- my $table_name_ur = $future->quote($table->name);
-
- my ( @comments );
-
- push @comments, "\n\n--\n-- Table: $table_name_ur\n--"
- unless $no_comments;
-
- push @comments, map { "-- $_" } $table->comments;
-
push @foreign_constraints, map $future->foreign_key_constraint($_),
grep { $_->type eq FOREIGN_KEY } $table->get_constraints;
$output .= join( "\n\n",
- @comments,
+ $future->table_comments($table),
# index defs
$future->table($table),
(map $future->unique_constraint_multiple($_),