line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Tapper::CLI::DbDeploy::Command::upgrade; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TAPPER'; |
3
|
|
|
|
|
|
|
$Tapper::CLI::DbDeploy::Command::upgrade::VERSION = '5.0.6'; |
4
|
1
|
|
|
1
|
|
939
|
use 5.010; |
|
1
|
|
|
|
|
4
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
20
|
|
7
|
1
|
|
|
1
|
|
21
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
41
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
7
|
use parent 'App::Cmd::Command'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
60
|
use Tapper::Model 'model'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
58
|
|
12
|
1
|
|
|
1
|
|
8
|
use Tapper::CLI::DbDeploy; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
7
|
|
13
|
1
|
|
|
1
|
|
214
|
use Tapper::Config; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
21
|
|
14
|
1
|
|
|
1
|
|
5
|
use Data::Dumper; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
54
|
|
15
|
1
|
|
|
1
|
|
7
|
use File::ShareDir 'module_dir'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
51
|
|
16
|
1
|
|
|
1
|
|
7
|
use Tapper::Schema; # for module_dir |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
406
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub opt_spec { |
19
|
|
|
|
|
|
|
return ( |
20
|
0
|
|
|
0
|
1
|
|
[ "verbose", "some more informational output" ], |
21
|
|
|
|
|
|
|
[ "db=s", "STRING, one of: ReportsDB, TestrunDB" ], |
22
|
|
|
|
|
|
|
[ "env=s", "STRING, default=development; one of: live, development, test" ], |
23
|
|
|
|
|
|
|
[ "upgradedir=s", "STRING, directory where upgradefiles are stored, default=./upgrades/" ], |
24
|
|
|
|
|
|
|
[ "fromversion=s","STRING" ], |
25
|
|
|
|
|
|
|
[ "toversion=s", "STRING" ], |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# aktuelle Version und Diff erzeugen zur gewünschten vorherigen |
30
|
|
|
|
|
|
|
# perl -Ilib -MTapper::Schema::ReportsDB -e 'Tapper::Schema::TestrunDB->connect("DBI:SQLite:foo")->create_ddl_dir([qw/MySQL SQLite PostgreSQL/], undef, "upgrades/", "2.010012") or die' |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub abstract { |
33
|
0
|
|
|
0
|
1
|
|
'Upgrade a database schema' |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub usage_desc |
37
|
|
|
|
|
|
|
{ |
38
|
0
|
|
|
0
|
1
|
|
my ($self, $opt, $args) = @_; |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
my $allowed_opts = join ' ', map { '--'.$_ } $self->_allowed_opts(); |
|
0
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
"tapper-db-deploy upgrade --db=DBNAME [ --verbose | --env=s ]"; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub _allowed_opts { |
45
|
0
|
|
|
0
|
|
|
my ($self, $opt, $args) = @_; |
46
|
0
|
|
|
|
|
|
my @allowed_opts = map { $_->[0] } $self->opt_spec(); |
|
0
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub validate_args { |
50
|
0
|
|
|
0
|
1
|
|
my ($self, $opt, $args) = @_; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# print "opt = ", Dumper($opt); |
53
|
|
|
|
|
|
|
# print "args = ", Dumper($args); |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
my $ok = 1; |
56
|
0
|
0
|
|
|
|
|
if (not $opt->{db}) |
|
|
0
|
|
|
|
|
|
57
|
|
|
|
|
|
|
{ |
58
|
0
|
|
|
|
|
|
say "Missing argument --db\n"; |
59
|
0
|
|
|
|
|
|
$ok = 0; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
elsif (not $opt->{db} = 'TestrunDB') |
62
|
|
|
|
|
|
|
{ |
63
|
0
|
|
|
|
|
|
say "Wrong DB name '".$opt->{db}."' (must be TestrunDB)"; |
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
|
|
0
|
|
|
|
my $upgradedir = $opt->{upgradedir} || module_dir('Tapper::Schema'); |
81
|
|
|
|
|
|
|
|
82
|
0
|
0
|
|
|
|
|
model($db)->upgrade_directory($upgradedir) if $upgradedir; |
83
|
0
|
|
|
|
|
|
model($db)->upgrade; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
# perl -Ilib bin/tapper-db-deploy upgrade --db=TestrunDB |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
1; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
__END__ |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=pod |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=encoding UTF-8 |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 NAME |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Tapper::CLI::DbDeploy::Command::upgrade |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 AUTHOR |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
AMD OSRC Tapper Team <tapper@amd64.org> |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
This software is Copyright (c) 2020 by Advanced Micro Devices, Inc.. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
This is free software, licensed under: |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
The (two-clause) FreeBSD License |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=cut |