1 package DBIx::Class::DeploymentHandler::ExplicitVersions;
3 use Method::Signatures::Simple;
7 isa => 'DBIx::Class::Schema',
10 handles => [qw( ddl_filename schema_version )],
14 isa => 'DBIx::Class::ResultSet',
17 handles => [qw( is_installed db_version )],
20 method _build_version_rs {
21 $self->schema->set_us_up_the_bomb;
22 $self->schema->resultset('__VERSION')
30 has ordered_versions => (
35 my $to_version = $_[0]->to_version;
36 my $db_version = $_[0]->db_version;
38 croak 'to_version not in ordered_versions'
39 unless grep { $to_version eq $_ } @{ $_[1] };
42 return if $_ eq $db_version;
43 croak 'to_version is before database version in ordered_versions'
55 method _inc_version_idx { $self->_version_idx($self->_version_idx + 1 ) }
57 method _build__version_idx {
58 my $start = $self->version_rs->db_version;
60 for (@{$self->ordered_versions}) {
62 if $_ eq $self->db_version;
65 croak 'database version not found in ordered_versions!';
68 method next_version_set {
70 if $self->ordered_versions->[$self->_version_idx] eq $self->to_version;
71 my $next_idx = $self->_inc_version_idx;
72 if ( $next_idx <= $#{ $self->ordered_versions }) {
74 $self->ordered_versions->[$next_idx - 1],
75 $self->ordered_versions->[$next_idx ],
82 __PACKAGE__->meta->make_immutable;
88 vim: ts=2 sw=2 expandtab