DeploymentHandler/VersionHandler/DatabaseToSchemaVersions.pm

filter: Statementstmt 82.1% 23 / 28 Branchbran 50.0% 5 / 10 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 80.0% 4 / 5 Podpod 0.0% 0 / 2 totaltotal 66.0% 33 / 50 CC 7 SCAR 16.4
CC
7
Cov
71%
previous_version_set
12.0
__ANON__
3.2
next_version_set
3.0
CRAP 5.2
« DeploymentHandler/DeployMethod/SQL/Translator/ScriptHelpers.pm ↑ Summary DeploymentHandler/WithReasonableDefaults.pm »
1 package DBIx::Class::DeploymentHandler::VersionHandler::DatabaseToSchemaVersions;
2 2 $DBIx::Class::DeploymentHandler::VersionHandler::DatabaseToSchemaVersions::VERSION = '0.002233';
3 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 # ABSTRACT: Go straight from Database to Schema version
6  
7 2 with 'DBIx::Class::DeploymentHandler::HandlesVersioning';
8  
9 2 has schema_version => (
10 is => 'ro',
11 required => 1,
12 );
13  
14 2 has initial_version => (
15 isa => 'Str',
16 is => 'ro',
17 required => 1,
18 );
19  
20 2 has to_version => ( # configuration
21 is => 'ro',
22 isa => 'Str',
23 lazy_build => 1,
24 );
25  
26 3 ▶sub _build_to_version { $_[0]->schema_version }
Subroutine _build_to_version: called CC=1 SCAR=0.0
27  
28 2 has once => (
29 is => 'rw',
30 isa => 'Bool',
31 default => undef,
32 );
33  
34 # provide backwards compatibility for initial_version/database_version
35 around BUILDARGS => sub {
36 6 ▶ my $orig = shift;
Subroutine __ANON__: called CC=3 SCAR=11.8
37 6 my $class = shift;
38  
39 6 my $args = $class->$orig(@_);
40 $args->{initial_version} = $args->{database_version}
41 6 ▶ if exists $args->{database_version} && !exists $args->{initial_version};
Branch: 1 branch
BranchTrueFalseTotal
if exists $args->{"database_version"} and not exists $args->{"initial_version"} 6 0 6
Condition33%1/3
exists $args->{"database_version"} and not exists $args->{"initial_version"}
!ll&&!rl&&r
006
MC/DC0%0/2
exists $args->{"database_version"} and not exists $args->{"initial_version"}
exists $args->{"database_version"} not exists $args->{"initial_version"}
Truth table33%1/3
A and not(B)
A= exists $args->{"database_version"}B= not exists $args->{"initial_version"}
ABresult
0X0
100
111
42 6 return $args;
43 2 };
44  
45 sub next_version_set {
46 11 ▶ my $self = shift;
Subroutine next_version_set: called CC=3 SCAR=11.0
Pod undocumented
47 return undef
48 11 ▶ if $self->once;
Branch: 1 branch
BranchTrueFalseTotal
if $self->once 5 6 11
49  
50 6 $self->once(!$self->once);
51 return undef
52 6 ▶ if $self->initial_version eq $self->to_version;
Branch: 1 branch
BranchTrueFalseTotal
if $self->initial_version eq $self->to_version 2 4 6
53 4 return [$self->initial_version, $self->to_version];
54 }
55  
56 sub previous_version_set {
57 0 ▶ my $self = shift;
Subroutine previous_version_set: not called CC=3 SCAR=24.8
Pod undocumented
58 return undef
59 0 ▶ if $self->once;
Branch: 1 branch
BranchTrueFalseTotal
if $self->once 0 0 0
60  
61 0 $self->once(!$self->once);
62 return undef
63 0 ▶ if $self->initial_version eq $self->to_version;
Branch: 1 branch
BranchTrueFalseTotal
if $self->initial_version eq $self->to_version 0 0 0
64 0 return [$self->initial_version, $self->to_version];
65 }
66  
67  
68 2 __PACKAGE__->meta->make_immutable;
69  
70 2 1;
71  
72 # vim: ts=2 sw=2 expandtab
73  
74 __END__
75  
76 =pod
77  
78 =head1 NAME
79  
80 DBIx::Class::DeploymentHandler::VersionHandler::DatabaseToSchemaVersions - Go straight from Database to Schema version
81  
82 =head1 SEE ALSO
83  
84 This class is an implementation of
85 L<DBIx::Class::DeploymentHandler::HandlesVersioning>. Pretty much all the
86 documentation is there.
87  
88 =head1 AUTHOR
89  
90 Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
91  
92 =head1 COPYRIGHT AND LICENSE
93  
94 This software is copyright (c) 2019 by Arthur Axel "fREW" Schmidt.
95  
96 This is free software; you can redistribute it and/or modify it under
97 the same terms as the Perl 5 programming language system itself.
98  
99 =cut
« DeploymentHandler/DeployMethod/SQL/Translator/ScriptHelpers.pm ↑ Summary DeploymentHandler/WithReasonableDefaults.pm »