DBIx-Class-DeploymentAdapter
view release on metacpan or search on metacpan
lib/DBIx/Class/DeploymentAdapter.pm view on Meta::CPAN
package DBIx::Class::DeploymentAdapter;
use 5.008001;
use strict;
use warnings;
our $VERSION = "0.09";
=encoding utf-8
=head1 NAME
DBIx::Class::DeploymentAdapter - Deployment handler adapter to your DBIC app, which offers some candy
=head1 SYNOPSIS
use DBIx::Class::DeploymentAdapter;
my $args = {
schema => $schema,
script_directory => './share/migrations',
databases => ['MySQL'],
sql_translator_args => { mysql_enable_utf8 => 1 },
};
$args->{to_version} = $to_version if $to_version;
$args->{force_overwrite} = $force_overwrite if $force_overwrite;
my $da = DBIx::Class::DeploymentAdapter->new($args);
=head1 DESCRIPTION
Deployment handler adapter to your DBIC app, which offers some candy
=cut
use DBIx::Class::DeploymentHandler;
use Moose;
has dh_store => (
is => "rw",
isa => "Maybe[Object]"
);
sub dh {
my ( $self, $args ) = @_;
if ( !$self->dh_store ) {
return unless $args && $args->{schema};
$args->{script_directory} ||= "./share/migrations";
$args->{databases} ||= ["MySQL"];
$args->{sql_translator_args} ||= { mysql_enable_utf8 => 1 };
my $dh = DBIx::Class::DeploymentHandler->new($args);
$self->dh_store($dh);
}
return $self->dh_store;
}
sub BUILD {
my $self = shift;
my $args = shift;
$self->dh($args);
}
=head2 install
Installs the schema files to the given Database
$da->install;
=cut
sub install {
my $self = shift;
my @params = @_;
return unless $self->dh;
$self->dh->install(@params);
}
=head2 prepare
Summarize all prepares from L<DBIx::Class::DeploymentHandler> in one Command
$da->prepare;
=cut
sub prepare {
my ($self) = @_;
return unless $self->dh;
my $start_version = $self->dh->database_version;
my $target_version = $self->dh->schema->schema_version;
$self->dh->prepare_install;
$self->dh->prepare_upgrade(
{
from_version => $start_version,
to_version => $target_version,
}
);
( run in 0.711 second using v1.01-cache-2.11-cpan-39bf76dae61 )