1 package DBIx::Class::DeploymentHandler::VersionHandler::Monotonic;
5 with 'DBIx::Class::DeploymentHandler::HandlesVersioning';
7 has schema_version => (
13 has database_version => (
25 sub _build_to_version { $_[0]->schema_version }
33 sub _inc_version { $_[0]->_version($_[0]->_version + 1 ) }
34 sub _dec_version { $_[0]->_version($_[0]->_version - 1 ) }
36 sub _build__version { $_[0]->database_version }
38 sub previous_version_set {
40 if ($self->to_version > $self->_version) {
41 croak "you are trying to downgrade and your current version is less\n".
42 "than the version you are trying to downgrade to. Either upgrade\n".
43 "or update your schema"
44 } elsif ( $self->to_version == $self->_version) {
48 return [$self->_version, $self->_version + 1];
52 sub next_version_set {
54 if ($self->to_version < $self->_version) {
55 croak "you are trying to upgrade and your current version is greater\n".
56 "than the version you are trying to upgrade to. Either downgrade\n".
57 "or update your schema"
58 } elsif ( $self->to_version == $self->_version) {
62 return [$self->_version - 1, $self->_version];
66 __PACKAGE__->meta->make_immutable;
72 vim: ts=2 sw=2 expandtab