# HG changeset patch # User Vincent Tondellier # Date 1407156669 -7200 # Node ID f65708dc1be16e01245987f14d00b6bb9840211e # Parent 006e82a1bcd0d4577c22bb3829ea089f26f6b22b Rename setup command to db diff -r 006e82a1bcd0 -r f65708dc1be1 lib/CrashTest/Commands/db.pm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/CrashTest/Commands/db.pm Mon Aug 04 14:51:09 2014 +0200 @@ -0,0 +1,62 @@ +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +package CrashTest::Commands::db; +use Mojo::Base 'Mojolicious::Command'; +use v5.12; + +use aliased 'DBIx::Class::DeploymentHandler' => 'DH'; +use CrashTest::Storage::Sql::Schema; + +# Short description +has description => 'Setup database.'; + +# Short usage message +has usage => <connect($self->app->config->{Storage}->{DSN}); + + my $dhargs = { + schema => $schema, + script_directory => "$FindBin::Bin/dbicdh", + sql_translator_args => { add_drop_table => 0 }, + force_overwrite => 0, + }; + + if($args[0] eq "prepare") { + $dhargs->{force_overwrite} = 1; + my $dh = DH->new($dhargs); + $dh->prepare_install; +# $dh->prepare_upgrade; + } elsif($args[0] eq "create") { + my $dh = DH->new($dhargs); + $dh->install; +# } elsif($args[0] eq "upgrade") { +# my $dh = DH->new($dhargs); +# $dh->upgrade; + } else { + say "Invalid arguments"; + exit 1; + } + +} + +1; diff -r 006e82a1bcd0 -r f65708dc1be1 lib/CrashTest/Commands/setup.pm --- a/lib/CrashTest/Commands/setup.pm Sun Aug 03 17:40:13 2014 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,48 +0,0 @@ -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -package CrashTest::Commands::setup; -use Mojo::Base 'Mojolicious::Command'; - -use aliased 'DBIx::Class::DeploymentHandler' => 'DH'; -use CrashTest::Storage::Sql::Schema; - -# Short description -has description => 'Setup database.'; - -# Short usage message -has usage => <connect($self->app->config->{Storage}->{DSN}); - - my $dh = DH->new( - { - schema => $schema, - script_directory => "$FindBin::Bin/dbicdh", - sql_translator_args => { add_drop_table => 0 }, - force_overwrite => 0, - } - ); - - $dh->prepare_install; - $dh->install; - -} - -1;