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