LasTres/script/prepare.pl

40 lines
857 B
Perl

#!/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 LasTres::Schema;
my $force_overwrite = 1;
unless ( GetOptions( 'force_overwrite!' => \$force_overwrite ) ) {
die "Invalid options";
}
my $schema = LasTres::Schema->Schema;
my $dh = DH->new(
{
schema => $schema,
script_directory => "$FindBin::Bin/../dbicdh",
databases => 'PostgreSQL',
sql_translator_args => { add_drop_table => 0 },
force_overwrite => $force_overwrite,
}
);
$dh->prepare_deploy;
eval {
$dh->prepare_upgrade({
from_version => $LasTres::Schema::VERSION - 1,
to_version => $LasTres::Schema::VERSION
});
};
if ($@) {
print "$@\n";
$dh->prepare_install;
}