--- /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 <http://www.gnu.org/licenses/>.
+
+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 => <<EOF;
+Usage: APPLICATION db [OPTIONS]
+
+ create Create database
+
+EOF
+
+sub run {
+ my ($self, @args) = @_;
+
+ my $schema = CrashTest::Storage::Sql::Schema->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;
--- 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 <http://www.gnu.org/licenses/>.
-
-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 => <<EOF;
-Usage: APPLICATION setup [OPTIONS]
-
-EOF
-
-sub run {
- my ($self, @args) = @_;
-
- my $schema = CrashTest::Storage::Sql::Schema->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;