From: Nigel Metheringham Date: Fri, 24 Sep 2010 14:47:56 +0000 (+0100) Subject: Added force_overwrite switch to install script X-Git-Tag: v0.001005~7 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3816b4c3e92e200335f59024d1cba339ab9f14e7;p=dbsrgits%2FDBIx-Class-DeploymentHandler.git Added force_overwrite switch to install script This is *so* useful when trying to get this to work... --- diff --git a/lib/DBIx/Class/DeploymentHandler/Manual/Intro.pod b/lib/DBIx/Class/DeploymentHandler/Manual/Intro.pod index d366ea8..f6a3acc 100644 --- a/lib/DBIx/Class/DeploymentHandler/Manual/Intro.pod +++ b/lib/DBIx/Class/DeploymentHandler/Manual/Intro.pod @@ -44,20 +44,32 @@ Our first script, C reads our schema file and creates the tables in the database. #!/usr/bin/env perl + use strict; use warnings; use aliased 'DBIx::Class::DeploymentHandler' => 'DH'; + use Getopt::Long; use FindBin; use lib "$FindBin::Bin/../lib"; use MyDatabase::Main; - my $schema = MyDatabase::Main->connect('dbi:SQLite:mydb'); - my $dh = DH->new({ - schema => $schema, - script_directory => "$FindBin::Bin/dbicdh", - databases => 'SQLite', - sql_translator_args => { add_drop_table => 0 }, - }); + my $force_overwrite = 0; + + unless ( GetOptions( 'force_overwrite!' => \$force_overwrite ) ) { + die "Invalid options"; + } + + my $schema = MyDatabase::Main->connect('dbi:SQLite:mydb.db'); + + my $dh = DH->new( + { + schema => $schema, + script_directory => "$FindBin::Bin/../dbicdh", + databases => 'SQLite', + sql_translator_args => { add_drop_table => 0 }, + force_overwrite => $force_overwrite, + } + ); $dh->prepare_install; $dh->install;