Commit | Line | Data |
c703d15d |
1 | package DBIx::Class::DeploymentHandler::VersionHandler::DatabaseToSchemaVersions; |
e70a1600 |
2 | use Moose; |
9deabd1f |
3 | |
4 | # ABSTRACT: Go straight from Database to Schema version |
5 | |
24794769 |
6 | with 'DBIx::Class::DeploymentHandler::HandlesVersioning'; |
2440e311 |
7 | |
b539a216 |
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', |
e86c0c07 |
22 | isa => 'Str', |
23 | lazy_build => 1, |
b539a216 |
24 | ); |
25 | |
26 | sub _build_to_version { $_[0]->schema_version } |
27 | |
24794769 |
28 | has once => ( |
29 | is => 'rw', |
30 | isa => 'Bool', |
31 | default => undef, |
e70a1600 |
32 | ); |
33 | |
24794769 |
34 | sub 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 |
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 | |
e70a1600 |
56 | |
57 | __PACKAGE__->meta->make_immutable; |
58 | |
59 | 1; |
60 | |
e52174e3 |
61 | # vim: ts=2 sw=2 expandtab |
62 | |
e70a1600 |
63 | __END__ |
64 | |
ec167a97 |
65 | =head1 SEE ALSO |
e52174e3 |
66 | |
ec167a97 |
67 | This class is an implementation of |
68 | L<DBIx::Class::DeploymentHandler::HandlesVersioning>. Pretty much all the |
69 | documentation is there. |