| 1 | package Tapper::CLI::DbDeploy::Command::makeschemadiffs; | ||||||||||||||||||||
| 2 | 2 | our $AUTHORITY = 'cpan:TAPPER'; | |||||||||||||||||||
| 3 | 2 | $Tapper::CLI::DbDeploy::Command::makeschemadiffs::VERSION = '5.0.8'; | |||||||||||||||||||
| 4 | 2 | ▶ | use 5.010; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 2 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 2 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 2 | ▶ | use parent 'App::Cmd::Command'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | 2 | ▶ | use Tapper::Model 'model'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | 2 | ▶ | use Tapper::CLI::DbDeploy; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 12 | 2 | ▶ | use Tapper::Config; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 13 | 2 | ▶ | use Data::Dumper; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 14 | 2 | ▶ | use File::ShareDir 'module_dir'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 15 | 2 | ▶ | use Tapper::Schema; # for module_dir | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 0 | ▶ | sub opt_spec { | ||||||||||||||||||
|
Subroutine
opt_spec: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 18 | return ( | ||||||||||||||||||||
| 19 | 0 | [ "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 | 0 | ▶ | sub abstract { | ||||||||||||||||||
|
Subroutine
abstract: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 28 | 0 | 'Save schema diff files for later upgrade' | |||||||||||||||||||
| 29 | } | ||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | sub usage_desc | ||||||||||||||||||||
| 32 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
usage_desc: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 33 | 0 | my ($self, $opt, $args) = @_; | |||||||||||||||||||
| 34 | 0 | my $allowed_opts = join ' ', map { '--'.$_ } $self->_allowed_opts($opt, $args); | |||||||||||||||||||
| 35 | 0 | "tapper-db-deploy makeschemadiffs --db=DBNAME [ --verbose | --env=s ]*"; | |||||||||||||||||||
| 36 | } | ||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | 0 | ▶ | sub _allowed_opts { | ||||||||||||||||||
|
Subroutine
_allowed_opts: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 39 | 0 | my ($self, $opt, $args) = @_; | |||||||||||||||||||
| 40 | 0 | my @allowed_opts = map { $_->[0] } $self->opt_spec(); | |||||||||||||||||||
| 41 | } | ||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | 0 | ▶ | sub validate_args { | ||||||||||||||||||
|
Subroutine
validate_args: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||
| 44 | 0 | 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 | ▶ | if (not $opt->{db}) | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 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 | ▶ | if (not $opt->{fromversion}) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 62 | { | ||||||||||||||||||||
| 63 | 0 | say "Missing argument --fromversion\n"; | |||||||||||||||||||
| 64 | 0 | $ok = 0; | |||||||||||||||||||
| 65 | } | ||||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | 0 | ▶ | return $ok if $ok; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 68 | 0 | die $self->usage->text; | |||||||||||||||||||
| 69 | } | ||||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | sub run | ||||||||||||||||||||
| 72 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
run: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||
| 73 | 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 | ▶ | my $upgradedir = $opt->{upgradedir} || module_dir('Tapper::Schema'); | ||||||||||||||||||
|
Condition0%0/3
$opt->{'upgradedir'} || module_dir('Tapper::Schema')
MC/DC0%0/2
$opt->{'upgradedir'} || module_dir('Tapper::Schema')
$opt->{'upgradedir'}
module_dir('Tapper::Schema')
Truth table0%0/3
A || B
A= $opt->{'upgradedir'}B= module_dir('Tapper::Schema')
| |||||||||||||||||||||
| 82 | 0 | ▶ | model($db)->upgrade_directory($upgradedir) if $upgradedir; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 83 | 0 | ▶ | model($db)->create_ddl_dir([qw/MySQL SQLite PostgreSQL/], | ||||||||||||||||||
|
Condition0%0/3
$upgradedir || model($db)->upgrade_directory
MC/DC0%0/2
$upgradedir || model($db)->upgrade_directory
$upgradedir
model($db)->upgrade_directory
Truth table0%0/3
A || B
A= $upgradedirB= model($db)->upgrade_directory
| |||||||||||||||||||||
| 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 | 2 | 1; | |||||||||||||||||||
| 95 | |||||||||||||||||||||
| 96 | __END__ | ||||||||||||||||||||