1 package DBIx::Class::DeploymentHandler::VersionHandler::ExplicitVersions;
3 use Method::Signatures::Simple;
6 with 'DBIx::Class::DeploymentHandler::HandlesVersioning';
8 has schema_version => (
14 has database_version => (
20 has to_version => ( # configuration
22 lazy_build => 1, # builder comes from another role...
23 # which is... probably not how we want it
26 sub _build_to_version { $_[0]->schema_version }
28 has ordered_versions => (
33 my $to_version = $_[0]->to_version;
34 my $db_version = $_[0]->database_version;
36 croak 'to_version not in ordered_versions'
37 unless grep { $to_version eq $_ } @{ $_[1] };
40 return if $_ eq $db_version;
41 croak 'to_version is before database version in ordered_versions'
53 method _inc_version_idx { $self->_version_idx($self->_version_idx + 1 ) }
55 method _build__version_idx {
56 my $start = $self->database_version;
58 for (@{$self->ordered_versions}) {
60 if $_ eq $self->database_version;
63 croak 'database version not found in ordered_versions!';
66 sub next_version_set { # sub instead of method because of when roles get composed
69 if $self->ordered_versions->[$self->_version_idx] eq $self->to_version;
71 my $next_idx = $self->_inc_version_idx;
73 $self->ordered_versions->[$next_idx - 1],
74 $self->ordered_versions->[$next_idx ],
75 ] if $next_idx <= $#{ $self->ordered_versions };
77 croak 'this should never happen';
80 __PACKAGE__->meta->make_immutable;
86 vim: ts=2 sw=2 expandtab