From: Justin Hunter Date: Tue, 14 Jul 2009 23:53:09 +0000 (-0700) Subject: move these to ::Producer::SQL:: X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=dd4ef34d8262ea679b6c64b67c7cf447c48e90e6;p=dbsrgits%2FSQL-Translator-2.0-ish.git move these to ::Producer::SQL:: --- diff --git a/lib/SQL/Translator/Producer/PostgreSQL.pm b/lib/SQL/Translator/Producer/PostgreSQL.pm deleted file mode 100644 index 0c7550b..0000000 --- a/lib/SQL/Translator/Producer/PostgreSQL.pm +++ /dev/null @@ -1,6 +0,0 @@ -package SQL::Translator::Producer::PostgreSQL; -use namespace::autoclean; -use Moose::Role; -use SQL::Translator::Constants qw(:sqlt_types); - -1; diff --git a/lib/SQL/Translator/Producer/SQLite.pm b/lib/SQL/Translator/Producer/SQLite.pm deleted file mode 100644 index 7aa9bb8..0000000 --- a/lib/SQL/Translator/Producer/SQLite.pm +++ /dev/null @@ -1,55 +0,0 @@ -package SQL::Translator::Producer::SQLite; -use namespace::autoclean; -use Moose::Role; -use SQL::Translator::Constants qw(:sqlt_types); - -my %data_type_mapping = ( - SQL_LONGVARCHAR() => 'text', - SQL_TIMESTAMP() => 'timestamp', - SQL_INTEGER() => 'integer', - SQL_CHAR() => 'character', - SQL_VARCHAR() => 'varchar', - SQL_BIGINT() => 'integer', -); - -sub _create_table { - my $self = shift; - my $table = shift; - - my $no_comments = $self->no_comments; - my $sqlite_version = 0; - - my $create_table; - my (@create, @column_defs, @index_defs, @constraint_defs); - - $create_table .= 'DROP TABLE ' . $table->name . ";\n" if $self->drop_table; - $create_table .= 'CREATE TABLE ' . $table->name . " (\n"; - - push @column_defs, $self->_create_column($_) for values %{$table->columns}; - $create_table .= join(",\n", map { ' ' . $_ } @column_defs ) . "\n)"; - - print $create_table . ";\n"; - return (@create, $create_table, @index_defs, @constraint_defs ); -} - -sub _create_column { - my $self = shift; - my $column = shift; - - my $size = $column->data_type == SQL_TIMESTAMP() ? undef : $column->size; - my $default_value = $column->default_value; - $default_value =~ s/^now[()]*/CURRENT_TIMESTAMP/i if $default_value; - - my $column_def; - $column_def = $column->name . ' '; - $column_def .= defined $data_type_mapping{$column->data_type} - ? $data_type_mapping{$column->data_type} - : $column->data_type; - #$column_def .= '(' . $column->size . ')' if $size; - $column_def .= ' NOT NULL' unless $column->is_nullable; - $column_def .= ' PRIMARY KEY' if $column->is_auto_increment; - $column_def .= ' DEFAULT ' . $default_value if $column->default_value && !$column->is_auto_increment; - $column_def; -} - -1;