sub table {
my ($self, $table) = @_;
- 'CREATE TABLE ' . $self->quote($table->name) . " (\n".
- join( ",\n",
- map { " $_" }
- $self->fields($table),
- $self->constraints($table),
- ) .
- "\n);",
+ join ( "\n\n",
+ $self->table_comments($table),
+ 'CREATE TABLE ' . $self->quote($table->name) . " (\n".
+ join( ",\n",
+ map { " $_" }
+ $self->fields($table),
+ $self->constraints($table),
+ ) .
+ "\n);"
+ )
+}
+
+sub unique_constraints_multiple {
+ my ($self, $table) = @_;
+ (map $self->unique_constraint_multiple($_),
+ grep {
+ $_->type eq UNIQUE &&
+ grep { $_->is_nullable } $_->fields
+ } $table->get_constraints)
}
sub drop_table {
( map $self->field($_), $table->get_fields )
}
+sub indices {
+ my ($self, $table) = @_;
+ (map $self->index($_), $table->get_indices)
+}
+
sub nullable { 'NULL' }
sub header_comments { header_comment() . "\n" if $_[0]->add_comments }
for my $table ( grep { $_->name } $schema->get_tables ) {
$output .= join( "\n\n",
- $future->table_comments($table),
- # index defs
$future->table($table),
- (map $future->unique_constraint_multiple($_),
- grep {
- $_->type eq UNIQUE &&
- grep { $_->is_nullable } $_->fields
- } $table->get_constraints),
-
- (map $future->index($_), $table->get_indices)
+ $future->unique_constraints_multiple($table),
+ $future->indices($table),
);
}