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