2 class SQL::Translator::Producer {
3 use MooseX::Types::Moose qw(Bool Str);
4 use SQL::Translator::Types qw(Column Schema Table);
12 has 'no_comments' => (
27 my $schema = $self->schema;
29 $self->_create_table($_) for values %{$schema->tables};
32 method _create_table(Table $table) {
34 my $add_drop_table = 1;
35 my $sqlite_version = 0;
38 my (@column_defs, @index_defs, @constraint_defs);
40 $create_table .= 'DROP TABLE ' . $table->name . ";\n" if $add_drop_table;
41 $create_table .= 'CREATE TABLE ' . $table->name . " (\n";
43 push @column_defs, $self->_create_column($_) for values %{$table->columns};
44 $create_table .= join(",\n", map { ' ' . $_ } @column_defs ) . "\n)";
45 print $create_table . "\n";
48 method _create_column(Column $column) {
50 $column_def = $column->name . ' ' . $column->data_type;
51 $column_def .= '(' . $column->size . ')' if $column->size;
52 $column_def .= ' NOT NULL' unless $column->is_nullable;