line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DBIx::SchemaChecksum::App::ShowUpdatePath; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: Show the update path |
4
|
|
|
|
|
|
|
our $VERSION = '1.103'; # VERSION |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
22964
|
use 5.010; |
|
1
|
|
|
|
|
5
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
483
|
use MooseX::App::Command; |
|
1
|
|
|
|
|
471910
|
|
|
1
|
|
|
|
|
5
|
|
9
|
|
|
|
|
|
|
extends qw(DBIx::SchemaChecksum::App); |
10
|
1
|
|
|
1
|
|
965964
|
use Carp qw(croak); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
73
|
|
11
|
1
|
|
|
1
|
|
8
|
use Moose::Util::TypeConstraints; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
13
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
option 'from_checksum' => ( is => 'ro', isa => 'Str',documentation => q[start update path from this checksum] |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
option 'output' => ( is => 'ro', default=>'nice',isa=>enum([qw[ nice concat psql ]]),); |
16
|
|
|
|
|
|
|
option 'dbname' => ( is=>'ro', isa=>'Str', default=>'datebase_name'); |
17
|
|
|
|
|
|
|
option '+sqlsnippetdir' => ( required => 1); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has '_concat' => (is=>'rw',isa=>'Str', default=>''); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub run { |
22
|
1
|
|
|
1
|
|
2922
|
my $self = shift; |
23
|
|
|
|
|
|
|
|
24
|
1
|
|
33
|
|
|
57
|
$self->show_update_path( $self->from_checksum || $self->checksum ); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub show_update_path { |
29
|
5
|
|
|
5
|
|
14
|
my ($self, $this_checksum) = @_; |
30
|
5
|
|
|
|
|
181
|
my $update_path = $self->_update_path; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my $update = $update_path->{$this_checksum} |
33
|
5
|
100
|
|
|
|
17
|
if ( exists $update_path->{$this_checksum} ); |
34
|
|
|
|
|
|
|
|
35
|
5
|
100
|
|
|
|
12
|
unless ($update) { |
36
|
1
|
50
|
|
|
|
33
|
print "# " if $self->output eq 'psql'; |
37
|
1
|
50
|
|
|
|
33
|
print "-- " if $self->output eq 'concat'; |
38
|
1
|
|
|
|
|
18
|
say "No update found that's based on $this_checksum."; |
39
|
1
|
|
|
|
|
18
|
return; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
4
|
100
|
|
|
|
13
|
if ( $update->[0] eq 'SAME_CHECKSUM' ) { |
43
|
2
|
|
|
|
|
8
|
my ( $file, $post_checksum ) = splice( @$update, 1, 2 ); |
44
|
2
|
|
|
|
|
7
|
$self->report_file($file, $post_checksum); |
45
|
2
|
|
|
|
|
317
|
$self->show_update_path($post_checksum); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
else { |
48
|
2
|
|
|
|
|
98
|
$self->report_file($update->[0],$update->[1]); |
49
|
2
|
|
|
|
|
399
|
$self->show_update_path($update->[1]); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub report_file { |
54
|
4
|
|
|
4
|
|
13
|
my ($self, $file, $checksum) = @_; |
55
|
|
|
|
|
|
|
|
56
|
4
|
50
|
|
|
|
199
|
if ($self->output eq 'nice') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
57
|
4
|
|
|
|
|
151
|
say $file->relative($self->sqlsnippetdir) ." ($checksum)"; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
elsif ($self->output eq 'psql') { |
60
|
0
|
|
|
|
|
|
say 'psql '.$self->dbname.' -1 -f '.$file->relative($self->sqlsnippetdir); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
elsif ($self->output eq 'concat') { |
63
|
0
|
|
|
|
|
|
say "\n-- file: ".$file->relative($self->sqlsnippetdir)."\n".join('',$file->slurp)."\n"; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable(); |
68
|
|
|
|
|
|
|
1; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
__END__ |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=pod |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=encoding UTF-8 |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 NAME |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
DBIx::SchemaChecksum::App::ShowUpdatePath - Show the update path |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 VERSION |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
version 1.103 |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 DESCRIPTION |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Show the whole update path starting from the current checksum, or from |
87
|
|
|
|
|
|
|
the one provided via C<--from_checksum>. Use 'C<--output concat>' to |
88
|
|
|
|
|
|
|
concat all changes to STDOUT. Use 'C<--output psql --dbname your-db>' |
89
|
|
|
|
|
|
|
to print some C<psql> commands to apply changes. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 AUTHORS |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=over 4 |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=item * |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Thomas Klausner <domm@plix.at> |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=item * |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Maroš Kollár <maros@cpan.org> |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=item * |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Klaus Ita <koki@worstofall.com> |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=back |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
This software is copyright (c) 2012 - 2021 by Thomas Klausner, Maroš Kollár, Klaus Ita. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
114
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=cut |