line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::Sqitch::Command::check; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
1776
|
use 5.010; |
|
2
|
|
|
|
|
8
|
|
4
|
2
|
|
|
2
|
|
19
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
44
|
|
5
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
57
|
|
6
|
2
|
|
|
2
|
|
15
|
use utf8; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
13
|
|
7
|
2
|
|
|
2
|
|
43
|
use Moo; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
12
|
|
8
|
2
|
|
|
2
|
|
800
|
use Types::Standard qw(Str HashRef); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
26
|
|
9
|
2
|
|
|
2
|
|
1701
|
use App::Sqitch::X qw(hurl); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
28
|
|
10
|
2
|
|
|
2
|
|
603
|
use Locale::TextDomain qw(App-Sqitch); |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
26
|
|
11
|
2
|
|
|
2
|
|
427
|
use List::Util qw(first); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
123
|
|
12
|
2
|
|
|
2
|
|
15
|
use namespace::autoclean; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
23
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
extends 'App::Sqitch::Command'; |
15
|
|
|
|
|
|
|
with 'App::Sqitch::Role::ContextCommand'; |
16
|
|
|
|
|
|
|
with 'App::Sqitch::Role::ConnectingCommand'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $VERSION = 'v1.4.0'; # VERSION |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has target => ( |
21
|
|
|
|
|
|
|
is => 'ro', |
22
|
|
|
|
|
|
|
isa => Str, |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
has from_change => ( |
26
|
|
|
|
|
|
|
is => 'ro', |
27
|
|
|
|
|
|
|
isa => Str, |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
has to_change => ( |
31
|
|
|
|
|
|
|
is => 'ro', |
32
|
|
|
|
|
|
|
isa => Str, |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
has variables => ( |
36
|
|
|
|
|
|
|
is => 'ro', |
37
|
|
|
|
|
|
|
isa => HashRef, |
38
|
|
|
|
|
|
|
lazy => 1, |
39
|
|
|
|
|
|
|
default => sub { {} }, |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub options { |
43
|
|
|
|
|
|
|
return qw( |
44
|
|
|
|
|
|
|
target|t=s |
45
|
|
|
|
|
|
|
from-change|from=s |
46
|
|
|
|
|
|
|
to-change|to=s |
47
|
|
|
|
|
|
|
set|s=s% |
48
|
|
|
|
|
|
|
); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub configure { |
52
|
|
|
|
|
|
|
my ( $class, $config, $opt ) = @_; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
my %params = map { |
55
|
|
|
|
|
|
|
$_ => $opt->{$_} |
56
|
|
|
|
|
|
|
} grep { |
57
|
|
|
|
|
|
|
exists $opt->{$_} |
58
|
|
|
|
|
|
|
} qw(target from_change to_change); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
if ( my $vars = $opt->{set} ) { |
61
|
|
|
|
|
|
|
$params{variables} = $vars; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
return \%params; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub _collect_vars { |
68
|
15
|
|
|
15
|
|
672
|
my ($self, $target) = @_; |
69
|
15
|
|
|
|
|
306
|
my $cfg = $self->sqitch->config; |
70
|
|
|
|
|
|
|
return ( |
71
|
15
|
|
|
|
|
75
|
%{ $cfg->get_section(section => 'core.variables') }, |
72
|
15
|
|
|
|
|
50
|
%{ $cfg->get_section(section => 'deploy.variables') }, |
73
|
15
|
|
|
|
|
63
|
%{ $cfg->get_section(section => 'check.variables') }, |
74
|
15
|
|
|
|
|
306
|
%{ $target->variables }, # includes engine |
75
|
15
|
|
|
|
|
117
|
%{ $self->variables }, # --set |
|
15
|
|
|
|
|
659
|
|
76
|
|
|
|
|
|
|
); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub execute { |
80
|
10
|
|
|
10
|
1
|
26294
|
my $self = shift; |
81
|
10
|
|
|
|
|
71
|
my ($targets, $changes) = $self->parse_args( |
82
|
|
|
|
|
|
|
target => $self->target, |
83
|
|
|
|
|
|
|
args => \@_, |
84
|
|
|
|
|
|
|
); |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# Warn on multiple targets. |
87
|
8
|
|
|
|
|
404
|
my $target = shift @{ $targets }; |
|
8
|
|
|
|
|
19
|
|
88
|
|
|
|
|
|
|
$self->warn(__x( |
89
|
|
|
|
|
|
|
'Too many targets specified; connecting to {target}', |
90
|
|
|
|
|
|
|
target => $target->name, |
91
|
8
|
100
|
|
|
|
16
|
)) if @{ $targets }; |
|
8
|
|
|
|
|
27
|
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# Warn on too many changes. |
94
|
8
|
|
100
|
|
|
194
|
my $from = $self->from_change // shift @{ $changes }; |
|
5
|
|
|
|
|
20
|
|
95
|
8
|
|
100
|
|
|
26
|
my $to = $self->to_change // shift @{ $changes }; |
|
5
|
|
|
|
|
14
|
|
96
|
|
|
|
|
|
|
$self->warn(__x( |
97
|
|
|
|
|
|
|
'Too many changes specified; checking from "{from}" to "{to}"', |
98
|
|
|
|
|
|
|
from => $from, |
99
|
|
|
|
|
|
|
to => $to, |
100
|
8
|
100
|
|
|
|
12
|
)) if @{ $changes }; |
|
8
|
|
|
|
|
26
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
# Now get to work. |
103
|
8
|
|
|
|
|
894
|
my $engine = $target->engine; |
104
|
8
|
|
|
|
|
1224
|
$engine->set_variables( $self->_collect_vars($target) ); |
105
|
8
|
|
|
|
|
204
|
$engine->check($from, $to); |
106
|
8
|
|
|
|
|
188
|
return $self; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
1; |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
__END__ |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 Name |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
App::Sqitch::Command::check - Runs various checks and prints a report |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 Synopsis |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
my $cmd = App::Sqitch::Command::check->new(%params); |
120
|
|
|
|
|
|
|
$cmd->execute; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 Description |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
If you want to know how to use the C<check> command, you probably want to be |
125
|
|
|
|
|
|
|
reading C<sqitch-check>. But if you really want to know how the C<check> command |
126
|
|
|
|
|
|
|
works, read on. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 Interface |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head2 Attributes |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head3 C<target_name> |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
The name or URI of the database target as specified by the C<--target> option. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head3 C<target> |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
An L<App::Sqitch::Target> object from which to perform the checks. Must be |
139
|
|
|
|
|
|
|
instantiated by C<execute()>. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head3 C<from_change> |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Change from which to check changes. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head3 C<to_change> |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Change up to which to check changes. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head2 Instance Methods |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head3 C<execute> |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
$check->execute; |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
Executes the check command. The current state of the target database will be |
156
|
|
|
|
|
|
|
compared to the plan in order to show where things stand. |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head1 See Also |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=over |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=item L<sqitch-check> |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
Documentation for the C<check> command to the Sqitch command-line client. |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=item L<sqitch> |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
The Sqitch command-line client. |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=back |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head1 Author |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
David E. Wheeler <david@justatheory.com> |
175
|
|
|
|
|
|
|
Matthieu Foucault <matthieu@button.is> |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head1 License |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
Copyright (c) 2012-2023 iovation Inc., David E. Wheeler, Button Inc. |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy |
182
|
|
|
|
|
|
|
of this software and associated documentation files (the "Software"), to deal |
183
|
|
|
|
|
|
|
in the Software without restriction, including without limitation the rights |
184
|
|
|
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
185
|
|
|
|
|
|
|
copies of the Software, and to permit persons to whom the Software is |
186
|
|
|
|
|
|
|
furnished to do so, subject to the following conditions: |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in all |
189
|
|
|
|
|
|
|
copies or substantial portions of the Software. |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
192
|
|
|
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
193
|
|
|
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
194
|
|
|
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
195
|
|
|
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
196
|
|
|
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
197
|
|
|
|
|
|
|
SOFTWARE. |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=cut |