add missing newline for no-linenumber-change dzil
[dbsrgits/DBIx-Class-DeploymentHandler.git] / lib / DBIx / Class / DeploymentHandler / VersionHandler / DatabaseToSchemaVersions.pm
CommitLineData
c703d15d 1package DBIx::Class::DeploymentHandler::VersionHandler::DatabaseToSchemaVersions;
97aa9a74 2
e70a1600 3use Moose;
9deabd1f 4
5# ABSTRACT: Go straight from Database to Schema version
6
24794769 7with 'DBIx::Class::DeploymentHandler::HandlesVersioning';
2440e311 8
b539a216 9has schema_version => (
10 isa => 'Str',
11 is => 'ro',
12 required => 1,
13);
14
15has database_version => (
16 isa => 'Str',
17 is => 'ro',
18 required => 1,
19);
20
21has to_version => ( # configuration
22 is => 'ro',
e86c0c07 23 isa => 'Str',
24 lazy_build => 1,
b539a216 25);
26
27sub _build_to_version { $_[0]->schema_version }
28
24794769 29has once => (
30 is => 'rw',
31 isa => 'Bool',
32 default => undef,
e70a1600 33);
34
24794769 35sub next_version_set {
36 my $self = shift;
37 return undef
38 if $self->once;
e70a1600 39
24794769 40 $self->once(!$self->once);
41 return undef
fb105cfa 42 if $self->database_version eq $self->to_version;
43 return [$self->database_version, $self->to_version];
e70a1600 44}
45
f344dd91 46sub previous_version_set {
47 my $self = shift;
48 return undef
49 if $self->once;
50
51 $self->once(!$self->once);
52 return undef
53 if $self->database_version eq $self->to_version;
54 return [$self->database_version, $self->to_version];
55}
56
e70a1600 57
58__PACKAGE__->meta->make_immutable;
59
601;
61
e52174e3 62# vim: ts=2 sw=2 expandtab
63
e70a1600 64__END__
65
ec167a97 66=head1 SEE ALSO
e52174e3 67
ec167a97 68This class is an implementation of
69L<DBIx::Class::DeploymentHandler::HandlesVersioning>. Pretty much all the
70documentation is there.