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