Commit | Line | Data |
7606fd62 |
1 | #!/usr/bin/env perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | use lib qw(lib t/lib); |
6 | |
7 | use DBICTest::Schema; |
8 | use SQL::Translator; |
9 | |
10 | my $schema = DBICTest::Schema->connect; |
11 | my $sql = scalar ($schema->storage->deployment_statements( |
12 | $schema, |
13 | 'SQLite', # close enough to SQL::Statement's format |
14 | undef, |
15 | undef, |
16 | { |
17 | parser_args => { |
18 | add_fk_index => 0, # doesn't use index statements, anyway |
19 | sources => [ |
20 | grep { !/^(?: |
21 | # unsupported data type tests |
22 | BindType|Money| |
23 | # DBD::DBM doesn't support single-column tables |
24 | Artwork|TimestampPrimaryKey| |
25 | # No support for views |
26 | Year2000CDs |
27 | )$/x } ($schema->sources) |
28 | ], |
29 | }, |
30 | producer_args => { no_transaction => 1 }, |
31 | quote_identifiers => 0, |
32 | no_comments => 1, |
33 | }, |
34 | )); |
35 | |
36 | # Clean up to remove non-supporting elements |
37 | my $field_type_lookahead = qr/(?=(?: NOT NULL)?(?:,|\n))/; |
38 | |
39 | $sql =~ s/^\s+FOREIGN KEY.+//gm; # FKs |
40 | $sql =~ s/^CREATE(?: UNIQUE)? INDEX.+\n\n//gm; # indexes |
41 | $sql =~ s/ DEFAULT .+?(?=,?\n)//g; # default values |
42 | $sql =~ s/^(\s+)text/$1texta/gm; # 'text' is a SQL reserved word |
43 | no warnings 'uninitialized'; |
44 | $sql =~ s/(?:date(?:time)?|time(?:stamp)?)$field_type_lookahead/varchar(20)/g; # date/timestamp fields (only support in some S:S DBDs) |
45 | $sql =~ s/character(\(\d+\))?$field_type_lookahead/char$1/g; # character --> char |
46 | |
47 | $sql =~ s/,(?=\n\);)//g; # dangling comma cleanup |
48 | |
49 | print $sql; |