Commit | Line | Data |
c703d15d |
1 | package DBIx::Class::DeploymentHandler::VersionHandler::DatabaseToSchemaVersions; |
e70a1600 |
2 | use Moose; |
3 | use Method::Signatures::Simple; |
4 | |
24794769 |
5 | with 'DBIx::Class::DeploymentHandler::HandlesVersioning'; |
2440e311 |
6 | |
b539a216 |
7 | has schema_version => ( |
8 | isa => 'Str', |
9 | is => 'ro', |
10 | required => 1, |
11 | ); |
12 | |
13 | has database_version => ( |
14 | isa => 'Str', |
15 | is => 'ro', |
16 | required => 1, |
17 | ); |
18 | |
19 | has to_version => ( # configuration |
20 | is => 'ro', |
21 | lazy_build => 1, # builder comes from another role... |
22 | # which is... probably not how we want it |
23 | ); |
24 | |
25 | sub _build_to_version { $_[0]->schema_version } |
26 | |
24794769 |
27 | has once => ( |
28 | is => 'rw', |
29 | isa => 'Bool', |
30 | default => undef, |
e70a1600 |
31 | ); |
32 | |
24794769 |
33 | sub next_version_set { |
34 | my $self = shift; |
35 | return undef |
36 | if $self->once; |
e70a1600 |
37 | |
24794769 |
38 | $self->once(!$self->once); |
39 | return undef |
fb105cfa |
40 | if $self->database_version eq $self->to_version; |
41 | return [$self->database_version, $self->to_version]; |
e70a1600 |
42 | } |
43 | |
e70a1600 |
44 | |
45 | __PACKAGE__->meta->make_immutable; |
46 | |
47 | 1; |
48 | |
49 | __END__ |
50 | |
51 | vim: ts=2 sw=2 expandtab |