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