9ff84176565ce0e75be8ec83e1646bf40216e07b
[dbsrgits/DBIx-Class-DeploymentHandler.git] / lib / DBIx / Class / DeploymentHandler / WithSqltDeployMethod.pm
1 package DBIx::Class::DeploymentHandler::WithSqltDeployMethod;
2 use Moose::Role;
3
4 # ABSTRACT: Delegate/Role for DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator
5
6 use DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator;
7
8 has deploy_method => (
9   does => 'DBIx::Class::DeploymentHandler::HandlesDeploy',
10   is  => 'ro',
11   lazy_build => 1,
12   handles =>  'DBIx::Class::DeploymentHandler::HandlesDeploy',
13 );
14
15 has upgrade_directory => (
16   isa      => 'Str',
17   is       => 'ro',
18   required => 1,
19   default  => 'sql',
20 );
21
22 has databases => (
23   coerce  => 1,
24   isa     => 'DBIx::Class::DeploymentHandler::Databases',
25   is      => 'ro',
26   default => sub { [qw( MySQL SQLite PostgreSQL )] },
27 );
28
29 has sql_translator_args => (
30   isa => 'HashRef',
31   is  => 'ro',
32   default => sub { {} },
33 );
34
35 sub _build_deploy_method {
36   my $self = shift;
37   my $args = {
38     schema              => $self->schema,
39     databases           => $self->databases,
40     upgrade_directory   => $self->upgrade_directory,
41     sql_translator_args => $self->sql_translator_args,
42   };
43
44   $args->{schema_version} = $self->schema_version if $self->has_schema_version;
45   DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator->new($args);
46 }
47
48 1;
49
50 # vim: ts=2 sw=2 expandtab
51
52 __END__
53
54 =head1 DELEGATION ROLE
55
56 This role is entirely for making delegation look like a role.  The actual
57 docs for the methods and attributes are at
58 L<DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator>