lib/CrashTest/Commands/setup.pm
author Vincent Tondellier <tonton+hg@team1664.org>
Sun, 03 Aug 2014 17:35:01 +0200
changeset 28 0df70b8735e3
parent 24 b69b7aa98a1d
permissions -rw-r--r--
Update Twitter bootstrap to 3.2.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;