cleanup modelines
[dbsrgits/DBIx-Class-DeploymentHandler.git] / lib / DBIx / Class / DeploymentHandler / VersionHandler / DatabaseToSchemaVersions.pm
1 package DBIx::Class::DeploymentHandler::VersionHandler::DatabaseToSchemaVersions;
2 use Moose;
3 use Method::Signatures::Simple;
4
5 with 'DBIx::Class::DeploymentHandler::HandlesVersioning';
6
7 has schema_version => (
8   isa      => 'Str',
9   is       => 'ro',
10   required => 1,
11 );
12
13 has database_version => (
14   isa      => 'Str',
15   is       => 'ro',
16   required => 1,
17 );
18
19 has to_version => ( # configuration
20   is         => 'ro',
21   lazy_build => 1, # builder comes from another role...
22                    # which is... probably not how we want it
23 );
24
25 sub _build_to_version { $_[0]->schema_version }
26
27 has once => (
28   is      => 'rw',
29   isa     => 'Bool',
30   default => undef,
31 );
32
33 sub next_version_set {
34   my $self = shift;
35   return undef
36     if $self->once;
37
38   $self->once(!$self->once);
39   return undef
40     if $self->database_version eq $self->to_version;
41   return [$self->database_version, $self->to_version];
42 }
43
44 sub previous_version_set {
45   my $self = shift;
46   return undef
47     if $self->once;
48
49   $self->once(!$self->once);
50   return undef
51     if $self->database_version eq $self->to_version;
52   return [$self->database_version, $self->to_version];
53 }
54
55
56 __PACKAGE__->meta->make_immutable;
57
58 1;
59
60 # vim: ts=2 sw=2 expandtab
61
62 __END__
63
64