X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=maint%2Fgen_sqlite_schema_files;h=03db9992bd4964c62572c7e68aad60b2ba13098d;hb=2f51deb1f0871f691eecac12c9b4c826836316ce;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..03db999 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,19 @@ 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(); +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 '-') {