X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=maint%2Fgen_sqlite_schema_files;h=a3793d33e7ff0088221130abc5b084d7e11d76ca;hb=f895c500473b77db4ecf185ed21530b821a14ed4;hp=9fa6a4c813de460f5862d432ec4e6e63c786d549;hpb=a2c296335a7a7190f412ed7470619189bb30766f;p=dbsrgits%2FDBIx-Class.git diff --git a/maint/gen_sqlite_schema_files b/maint/gen_sqlite_schema_files index 9fa6a4c..a3793d3 100755 --- a/maint/gen_sqlite_schema_files +++ b/maint/gen_sqlite_schema_files @@ -14,6 +14,7 @@ my $args = {}; $getopt->getoptions($args, qw/ ddl-out=s@ schema-class=s@ + deploy-to=s@ /); die "You need to specify one DDL output filename via --ddl-out\n" @@ -22,8 +23,20 @@ die "You need to specify one DDL output filename via --ddl-out\n" die "You need to specify one DBIC schema class via --schema-class\n" if @{$args->{'schema-class'}||[]} != 1; +die "You may not specify more than one deploy path via --deploy-to\n" + if @{$args->{'deploy-to'}||[]} > 1; -my $schema = use_module( $args->{'schema-class'}[0] )->connect(); +local $ENV{DBI_DSN}; +my $schema = use_module( $args->{'schema-class'}[0] )->connect( + $args->{'deploy-to'} + ? ( "DBI:SQLite:$args->{'deploy-to'}[0]", undef, undef, { on_connect_do => "PRAGMA synchronous = OFF" } ) + : () +); + +if ($args->{'deploy-to'}) { + file($args->{'deploy-to'}[0])->dir->mkpath; + $schema->deploy({ add_drop_table => 1 }); +} my $ddl_fh; if ($args->{'ddl-out'}[0] eq '-') {