1 package DBIx::Class::DeploymentHandler;
4 use Method::Signatures::Simple;
5 require DBIx::Class::Schema; # loaded for type constraint
6 require DBIx::Class::ResultSet; # loaded for type constraint
7 use Carp::Clan '^DBIx::Class::DeploymentHandler';
9 with 'DBIx::Class::DeploymentHandler::WithSqltDeployMethod',
10 'DBIx::Class::DeploymentHandler::WithDatabaseToSchemaVersions',
11 'DBIx::Class::DeploymentHandler::WithStandardVersionStorage';
14 use Moose::Util::TypeConstraints;
15 subtype 'DBIx::Class::DeploymentHandler::Databases'
16 => as 'ArrayRef[Str]';
18 coerce 'DBIx::Class::DeploymentHandler::Databases'
21 no Moose::Util::TypeConstraints;
25 isa => 'DBIx::Class::Schema',
28 handles => ['schema_version'],
31 has upgrade_directory => ( # configuration
38 has backup_directory => ( # configuration
41 predicate => 'has_backup_directory',
44 has to_version => ( # configuration
46 lazy_build => 1, # builder comes from another role...
47 # which is... probably not how we want it
50 sub _build_to_version { $_[0]->schema->schema_version }
52 has databases => ( # configuration
54 isa => 'DBIx::Class::DeploymentHandler::Databases',
56 default => sub { [qw( MySQL SQLite PostgreSQL )] },
59 has sqltargs => ( # configuration
62 default => sub { {} },
66 carp 'Install not possible as versions table already exists in database'
67 if $self->version_storage_is_installed;
69 my $new_version = $self->to_version;
74 $self->add_database_version({
75 version => $new_version,
77 # upgrade_sql => $upgrade_sql,
84 while ( my $version_list = $self->next_version_set ) {
85 $self->_upgrade_single_step($version_list);
87 $self->add_database_version({
88 version => $version_list->[-1],
90 # upgrade_sql => $upgrade_sql,
95 method backup { $self->storage->backup($self->backup_directory) }
97 __PACKAGE__->meta->make_immutable;
103 vim: ts=2 sw=2 expandtab