# 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;