require DBIx::Class::ResultSet; # loaded for type constraint
use Carp::Clan '^DBIx::Class::DeploymentHandler';
-with 'DBIx::Class::DeploymentHandler::WithSqltDeployMethod';
-with 'DBIx::Class::DeploymentHandler::WithDatabaseToSchemaVersions';
+with 'DBIx::Class::DeploymentHandler::WithSqltDeployMethod',
+ 'DBIx::Class::DeploymentHandler::WithDatabaseToSchemaVersions',
+ 'DBIx::Class::DeploymentHandler::WithStandardVersionStorage';
BEGIN {
use Moose::Util::TypeConstraints;
isa => 'DBIx::Class::Schema',
is => 'ro',
required => 1,
- handles => [qw( ddl_filename schema_version )],
);
has upgrade_directory => ( # configuration
predicate => 'has_backup_directory',
);
-has do_backup => ( # configuration
- isa => 'Bool',
- is => 'ro',
- default => undef,
-);
-
-has version_rs => (
- isa => 'DBIx::Class::ResultSet',
- is => 'ro',
- lazy_build => 1,
- handles => [qw( is_installed db_version )],
-);
-
-has to_version => (
+has to_version => ( # configuration
is => 'ro',
- lazy_build => 1,
+ lazy_build => 1, # builder comes from another role...
+ # which is... probably not how we want it
);
has databases => ( # configuration
method install {
carp 'Install not possible as versions table already exists in database'
- if $self->is_installed;
+ if $self->version_storage_is_installed;
my $new_version = $self->to_version;
if ($new_version) {
$self->_deploy;
- $self->version_rs->create({
+ $self->add_database_version({
version => $new_version,
# ddl => $ddl,
# upgrade_sql => $upgrade_sql,
}
}
-method upgrade {
+sub upgrade {
+ my $self = shift;
while ( my $version_list = $self->next_version_set ) {
$self->_upgrade_single_step($version_list);
+
+ $self->add_database_version({
+ version => $version_list->[-1],
+ # ddl => $ddl,
+ # upgrade_sql => $upgrade_sql,
+ });
}
}
+method backup { $self->storage->backup($self->backup_directory) }
+
__PACKAGE__->meta->make_immutable;
1;