Improve docs by linking from implementations to their roles
[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
24794769 6with 'DBIx::Class::DeploymentHandler::HandlesVersioning';
2440e311 7
b539a216 8has schema_version => (
9 isa => 'Str',
10 is => 'ro',
11 required => 1,
12);
13
14has database_version => (
15 isa => 'Str',
16 is => 'ro',
17 required => 1,
18);
19
20has to_version => ( # configuration
21 is => 'ro',
e86c0c07 22 isa => 'Str',
23 lazy_build => 1,
b539a216 24);
25
26sub _build_to_version { $_[0]->schema_version }
27
24794769 28has once => (
29 is => 'rw',
30 isa => 'Bool',
31 default => undef,
e70a1600 32);
33
24794769 34sub next_version_set {
35 my $self = shift;
36 return undef
37 if $self->once;
e70a1600 38
24794769 39 $self->once(!$self->once);
40 return undef
fb105cfa 41 if $self->database_version eq $self->to_version;
42 return [$self->database_version, $self->to_version];
e70a1600 43}
44
f344dd91 45sub 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
e70a1600 56
57__PACKAGE__->meta->make_immutable;
58
591;
60
e52174e3 61# vim: ts=2 sw=2 expandtab
62
e70a1600 63__END__
64
ec167a97 65=head1 SEE ALSO
e52174e3 66
ec167a97 67This class is an implementation of
68L<DBIx::Class::DeploymentHandler::HandlesVersioning>. Pretty much all the
69documentation is there.