disallow undef in versions
[dbsrgits/DBIx-Class-DeploymentHandler.git] / lib / DBIx / Class / DeploymentHandler / VersionHandler / DatabaseToSchemaVersions.pm
CommitLineData
c703d15d 1package DBIx::Class::DeploymentHandler::VersionHandler::DatabaseToSchemaVersions;
e70a1600 2use Moose;
9deabd1f 3
4# ABSTRACT: Go straight from Database to Schema version
5
e70a1600 6use Method::Signatures::Simple;
7
24794769 8with 'DBIx::Class::DeploymentHandler::HandlesVersioning';
2440e311 9
b539a216 10has schema_version => (
11 isa => 'Str',
12 is => 'ro',
13 required => 1,
14);
15
16has database_version => (
17 isa => 'Str',
18 is => 'ro',
19 required => 1,
20);
21
22has to_version => ( # configuration
23 is => 'ro',
e86c0c07 24 isa => 'Str',
25 lazy_build => 1,
b539a216 26);
27
28sub _build_to_version { $_[0]->schema_version }
29
24794769 30has once => (
31 is => 'rw',
32 isa => 'Bool',
33 default => undef,
e70a1600 34);
35
24794769 36sub next_version_set {
37 my $self = shift;
38 return undef
39 if $self->once;
e70a1600 40
24794769 41 $self->once(!$self->once);
42 return undef
fb105cfa 43 if $self->database_version eq $self->to_version;
44 return [$self->database_version, $self->to_version];
e70a1600 45}
46
f344dd91 47sub previous_version_set {
48 my $self = shift;
49 return undef
50 if $self->once;
51
52 $self->once(!$self->once);
53 return undef
54 if $self->database_version eq $self->to_version;
55 return [$self->database_version, $self->to_version];
56}
57
e70a1600 58
59__PACKAGE__->meta->make_immutable;
60
611;
62
e52174e3 63# vim: ts=2 sw=2 expandtab
64
e70a1600 65__END__
66
e52174e3 67