1 package DBIx::Class::DeploymentHandler::VersionHandler::ExplicitVersions;
5 # ABSTRACT: Define your own list of versions to use for migrations
9 with 'DBIx::Class::DeploymentHandler::HandlesVersioning';
11 has schema_version => (
17 has database_version => (
29 sub _build_to_version { $_[0]->schema_version }
31 has ordered_versions => (
37 has _index_of_versions => (
43 sub _build__index_of_versions {
46 for (@{ $_[0]->ordered_versions }) {
58 sub _build__version_idx { $_[0]->_index_of_versions->{$_[0]->database_version} }
60 sub _inc_version_idx { $_[0]->_version_idx($_[0]->_version_idx + 1 ) }
61 sub _dec_version_idx { $_[0]->_version_idx($_[0]->_version_idx - 1 ) }
64 sub next_version_set {
67 $self->_index_of_versions->{$self->to_version} <
70 croak "you are trying to upgrade and your current version is greater\n".
71 "than the version you are trying to upgrade to. Either downgrade\n".
72 "or update your schema"
73 } elsif ( $self->_version_idx == $self->_index_of_versions->{$self->to_version}) {
76 my $next_idx = $self->_inc_version_idx;
78 $self->ordered_versions->[$next_idx - 1],
79 $self->ordered_versions->[$next_idx ],
84 sub previous_version_set {
87 $self->_index_of_versions->{$self->to_version} >
90 croak "you are trying to downgrade and your current version is less\n".
91 "than the version you are trying to downgrade to. Either upgrade\n".
92 "or update your schema"
93 } elsif ( $self->_version_idx == $self->_index_of_versions->{$self->to_version}) {
96 my $next_idx = $self->_dec_version_idx;
98 $self->ordered_versions->[$next_idx + 1],
99 $self->ordered_versions->[$next_idx ],
104 __PACKAGE__->meta->make_immutable;
108 # vim: ts=2 sw=2 expandtab
114 This class is an implementation of
115 L<DBIx::Class::DeploymentHandler::HandlesVersioning>. Pretty much all the
116 documentation is there.