croak 'Install not possible as versions table already exists in database'
if $self->version_storage_is_installed;
- my $ddl = $self->_deploy;
+ my $ddl = $self->deploy;
$self->version_storage->add_database_version({
version => $self->to_version,
sub upgrade {
my $self = shift;
while ( my $version_list = $self->next_version_set ) {
- my ($ddl, $upgrade_sql) = @{$self->_upgrade_single_step($version_list)||[]};
+ my ($ddl, $upgrade_sql) = @{$self->upgrade_single_step($version_list)||[]};
$self->add_database_version({
version => $version_list->[-1],
}
}
-method backup { $self->storage->backup($self->backup_directory) }
+sub downgrade {
+ my $self = shift;
+ while ( my $version_list = $self->previous_version_set ) {
+ $self->downgrade_single_step($version_list);
-method deploy_version_storage {
- $self->
+ # do we just delete a row here? I think so but not sure
+ $self->delete_database_version({ version => $version_list->[-1] });
+ }
}
+method backup { $self->storage->backup($self->backup_directory) }
+
__PACKAGE__->meta->make_immutable;
1;
return catfile( $dirname, '001-auto.sql');
}
-sub _deploy {
+sub deploy {
my $self = shift;
my $storage = $self->storage;
return \@data;
}
-sub _downgrade_single_step {
+sub downgrade_single_step {
my $self = shift;
my @version_set = @{ shift @_ };
my @downgrade_files = @{$self->_ddl_schema_down_consume_filenames(
}
}
-sub _upgrade_single_step {
+sub upgrade_single_step {
my $self = shift;
my @version_set = @{ shift @_ };
my @upgrade_files = @{$self->_ddl_schema_up_consume_filenames(
requires 'prepare_install';
requires 'prepare_upgrade';
requires 'prepare_downgrade';
-requires '_upgrade_single_step';
-requires '_downgrade_single_step';
-requires '_deploy';
+requires 'upgrade_single_step';
+requires 'downgrade_single_step';
+requires 'deploy';
1;
{
my $warned = 0;
local $SIG{__WARN__} = sub{$warned = 1};
- $dm->_deploy;
+ $dm->deploy;
ok( $warned, 'deploy warns on sql errors' );
}
print {$common} qq<INSERT INTO Foo (bar, baz) VALUES ("hello", "world");\n\n>;
close $common;
- $dm->_upgrade_single_step([qw( 1.0 2.0 )]);
+ $dm->upgrade_single_step([qw( 1.0 2.0 )]);
is( $s->resultset('Foo')->search({
bar => 'hello',
baz => 'world',
baz => 'frew',
})
} 'schema is deployed';
- $dm->_downgrade_single_step([qw( 2.0 1.0 )]);
+ $dm->downgrade_single_step([qw( 2.0 1.0 )]);
dies_ok {
$s->resultset('Foo')->create({
bar => 'frew',
baz => 'frew',
})
} 'schema is downpgrayyed';
- $dm->_upgrade_single_step([qw( 1.0 2.0 )]);
+ $dm->upgrade_single_step([qw( 1.0 2.0 )]);
}
VERSION3: {
biff => 'frew',
})
} 'schema not deployed';
- $dm->_upgrade_single_step([qw( 2.0 3.0 )]);
+ $dm->upgrade_single_step([qw( 2.0 3.0 )]);
lives_ok {
$s->resultset('Foo')->create({
bar => 'frew',
rmtree(catfile(qw( t sql SQLite )));
rmtree(catfile(qw( t sql _generic )));
dies_ok {
- $dm->_upgrade_single_step([qw( 2.0 3.0 )]);
+ $dm->upgrade_single_step([qw( 2.0 3.0 )]);
} 'dies when sql dir does not exist';
}
done_testing;
bar => 'frew',
})
} 'schema not deployed';
- $dm->_deploy;
+ $dm->deploy;
lives_ok {
$s->resultset('Foo')->create({
bar => 'frew',
baz => 'frew',
})
} 'schema not uppgrayyed';
- $dm->_upgrade_single_step(['1.0', $version]);
+ $dm->upgrade_single_step(['1.0', $version]);
lives_ok {
$s->resultset('Foo')->create({
bar => 'frew',