$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"
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 '-') {