line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Tapper::CLI::DbDeploy::Command::makeschemadiffs; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TAPPER'; |
3
|
|
|
|
|
|
|
$Tapper::CLI::DbDeploy::Command::makeschemadiffs::VERSION = '5.0.6'; |
4
|
1
|
|
|
1
|
|
1125
|
use 5.010; |
|
1
|
|
|
|
|
5
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
8
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
7
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
5
|
use parent 'App::Cmd::Command'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
10
|
1
|
|
|
1
|
|
97
|
use Tapper::Model 'model'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
62
|
|
11
|
1
|
|
|
1
|
|
8
|
use Tapper::CLI::DbDeploy; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
12
|
1
|
|
|
1
|
|
304
|
use Tapper::Config; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
13
|
1
|
|
|
1
|
|
7
|
use Data::Dumper; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
46
|
|
14
|
1
|
|
|
1
|
|
6
|
use File::ShareDir 'module_dir'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
53
|
|
15
|
1
|
|
|
1
|
|
489
|
use Tapper::Schema; # for module_dir |
|
1
|
|
|
|
|
79
|
|
|
1
|
|
|
|
|
446
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub opt_spec { |
18
|
|
|
|
|
|
|
return ( |
19
|
0
|
|
|
0
|
1
|
|
[ "verbose", "some more informational output" ], |
20
|
|
|
|
|
|
|
[ "db=s", "STRING, one of: ReportsDB, TestrunDB" ], |
21
|
|
|
|
|
|
|
[ "env=s", "STRING, default=development; one of: live, development, test" ], |
22
|
|
|
|
|
|
|
[ "fromversion=s", "STRING, the version against we make the diff" ], |
23
|
|
|
|
|
|
|
[ "upgradedir=s", "STRING, directory here upgradefiles are stored, default=./upgrades/" ], |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub abstract { |
28
|
0
|
|
|
0
|
1
|
|
'Save schema diff files for later upgrade' |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub usage_desc |
32
|
|
|
|
|
|
|
{ |
33
|
0
|
|
|
0
|
1
|
|
my ($self, $opt, $args) = @_; |
34
|
0
|
|
|
|
|
|
my $allowed_opts = join ' ', map { '--'.$_ } $self->_allowed_opts($opt, $args); |
|
0
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
"tapper-db-deploy makeschemadiffs --db=DBNAME [ --verbose | --env=s ]*"; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub _allowed_opts { |
39
|
0
|
|
|
0
|
|
|
my ($self, $opt, $args) = @_; |
40
|
0
|
|
|
|
|
|
my @allowed_opts = map { $_->[0] } $self->opt_spec(); |
|
0
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub validate_args { |
44
|
0
|
|
|
0
|
1
|
|
my ($self, $opt, $args) = @_; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# print "self = ", Dumper($self); |
47
|
|
|
|
|
|
|
# print "opt = ", Dumper($opt); |
48
|
|
|
|
|
|
|
# print "args = ", Dumper($args); |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
my $ok = 1; |
51
|
0
|
0
|
|
|
|
|
if (not $opt->{db}) |
|
|
0
|
|
|
|
|
|
52
|
|
|
|
|
|
|
{ |
53
|
0
|
|
|
|
|
|
say "Missing argument --db\n"; |
54
|
0
|
|
|
|
|
|
$ok = 0; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
elsif (not $opt->{db} = 'TestrunDB') |
57
|
|
|
|
|
|
|
{ |
58
|
0
|
|
|
|
|
|
say "Wrong DB name '".$opt->{db}."' (must be TestrunDB)"; |
59
|
0
|
|
|
|
|
|
$ok = 0; |
60
|
|
|
|
|
|
|
} |
61
|
0
|
0
|
|
|
|
|
if (not $opt->{fromversion}) |
62
|
|
|
|
|
|
|
{ |
63
|
0
|
|
|
|
|
|
say "Missing argument --fromversion\n"; |
64
|
0
|
|
|
|
|
|
$ok = 0; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
0
|
0
|
|
|
|
|
return $ok if $ok; |
68
|
0
|
|
|
|
|
|
die $self->usage->text; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub run |
72
|
|
|
|
|
|
|
{ |
73
|
0
|
|
|
0
|
0
|
|
my ($self, $opt, $args) = @_; |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
local $DBIx::Class::Schema::Versioned::DBICV_DEBUG = 1; |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
Tapper::Config::_switch_context($opt->{env}); |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
my $db = $opt->{db}; |
80
|
0
|
|
|
|
|
|
my $fromversion = $opt->{fromversion}; |
81
|
0
|
|
0
|
|
|
|
my $upgradedir = $opt->{upgradedir} || module_dir('Tapper::Schema'); |
82
|
0
|
0
|
|
|
|
|
model($db)->upgrade_directory($upgradedir) if $upgradedir; |
83
|
0
|
|
0
|
|
|
|
model($db)->create_ddl_dir([qw/MySQL SQLite PostgreSQL/], |
84
|
|
|
|
|
|
|
undef, |
85
|
|
|
|
|
|
|
($upgradedir || model($db)->upgrade_directory), |
86
|
|
|
|
|
|
|
$fromversion |
87
|
|
|
|
|
|
|
); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# perl -Ilib bin/tapper-db-deploy makeschemadiffs --db=TestrunDB |
92
|
|
|
|
|
|
|
# perl -Ilib bin/tapper-db-deploy makeschemadiffs --upgradedir=$HOME/local/projects/Tapper/src/Tapper-Schema/upgrades/ --db=TestrunDB --fromversion=2.010009 |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
1; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
__END__ |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=pod |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=encoding UTF-8 |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 NAME |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Tapper::CLI::DbDeploy::Command::makeschemadiffs |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 AUTHOR |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
AMD OSRC Tapper Team <tapper@amd64.org> |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
This software is Copyright (c) 2020 by Advanced Micro Devices, Inc.. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
This is free software, licensed under: |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
The (two-clause) FreeBSD License |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=cut |