| 1 | package DBIO::DeploymentHandler::DeployMethod::Native; | ||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Native DBIO driver deploy (no SQL::Translator needed) | ||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 3 | our $VERSION = '0.900007'; | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use DBIO::Exception; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use DBIO::Util (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 3 | ▶ | use DBIO::Deploy::Base (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 3 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 7 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||
| 17 | 7 | my ($class, @args) = @_; | |||||||||||||||||||||||||||
| 18 | 7 | ▶ | my $args = @args == 1 ? $args[0] : { @args }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 19 | 7 | bless +{%$args}, $class; | |||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 0 | ▶ | sub schema { $_[0]->{schema} } | ||||||||||||||||||||||||||
|
Subroutine
schema: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 0 | ▶ | sub deploy { | ||||||||||||||||||||||||||
|
Subroutine
deploy: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 27 | 0 | my ($self, $args) = @_; | |||||||||||||||||||||||||||
| 28 | 0 | $self->_driver_deploy->install; | |||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 0 | ▶ | sub upgrade { | ||||||||||||||||||||||||||
|
Subroutine
upgrade: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 33 | 0 | my ($self, $args) = @_; | |||||||||||||||||||||||||||
| 34 | return $self->_driver_deploy->upgrade( | ||||||||||||||||||||||||||||
| 35 | defined $args && exists $args->{allow_destructive} | ||||||||||||||||||||||||||||
| 36 | 0 | ▶ | ? (allow_destructive => $args->{allow_destructive}) : () | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $args and exists $args->{"allow_destructive"}
MC/DC0%0/2
defined $args and exists $args->{"allow_destructive"}
defined $args
exists $args->{"allow_destructive"}
Truth table0%0/3
A and B
A= defined $argsB= exists $args->{"allow_destructive"}
| |||||||||||||||||||||||||||||
| 37 | ); | ||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 0 | ▶ | sub diff { | ||||||||||||||||||||||||||
|
Subroutine
diff: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 42 | 0 | my ($self, $args) = @_; | |||||||||||||||||||||||||||
| 43 | 0 | $self->_driver_deploy->diff; | |||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | # The native driver introspects + reconciles in one shot, so there is | ||||||||||||||||||||||||||||
| 47 | # nothing to "prepare" in advance. These exist to satisfy callers that | ||||||||||||||||||||||||||||
| 48 | # still expect the old DBIx::Class::DeploymentHandler contract. | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 0 | ▶ | sub prepare_deploy { } | ||||||||||||||||||||||||||
|
Subroutine
prepare_deploy: not called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 52 | 0 | ▶ | sub prepare_upgrade { } | ||||||||||||||||||||||||||
|
Subroutine
prepare_upgrade: not called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 53 | 0 | ▶ | sub prepare_resultsource_install { } | ||||||||||||||||||||||||||
|
Subroutine
prepare_resultsource_install: not called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 54 | 0 | ▶ | sub initialize { } | ||||||||||||||||||||||||||
|
Subroutine
initialize: not called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 0 | ▶ | sub install_resultsource { | ||||||||||||||||||||||||||
|
Subroutine
install_resultsource: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 57 | 0 | my ($self, $args) = @_; | |||||||||||||||||||||||||||
| 58 | # Handled by the driver's install | ||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 0 | ▶ | sub txn_do { | ||||||||||||||||||||||||||
|
Subroutine
txn_do: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 63 | 0 | my ($self, $code) = @_; | |||||||||||||||||||||||||||
| 64 | 0 | my $txn_wrap = $self->{txn_wrap}; | |||||||||||||||||||||||||||
| 65 | 0 | ▶ | return $code->() unless $txn_wrap; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 66 | 0 | my $guard = $self->schema->txn_scope_guard; | |||||||||||||||||||||||||||
| 67 | 0 | my $rv = $code->(); | |||||||||||||||||||||||||||
| 68 | 0 | $guard->commit; | |||||||||||||||||||||||||||
| 69 | 0 | return $rv; | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 0 | ▶ | sub _driver_deploy { | ||||||||||||||||||||||||||
|
Subroutine
_driver_deploy: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||
| 73 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 0 | my $storage = DBIO::Deploy::Base::driver_storage($self->schema->storage); | |||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 0 | ▶ | if ($storage->can('dbio_deploy_class')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 78 | 0 | my $deploy_class = $storage->dbio_deploy_class; | |||||||||||||||||||||||||||
| 79 | 0 | DBIO::Util::assert_class_name($deploy_class); | |||||||||||||||||||||||||||
| 80 | 0 | ▶ | DBIO::Exception->throw("Cannot load deploy class $deploy_class: $@") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 81 | unless eval "require $deploy_class; 1"; | ||||||||||||||||||||||||||||
| 82 | 0 | return $deploy_class->new(schema => $self->schema); | |||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 0 | ▶ | $storage->_determine_driver if $storage->can('_determine_driver'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 0 | my $driver_class = ref($storage); | |||||||||||||||||||||||||||
| 88 | 0 | (my $deploy_class = $driver_class) =~ s{::Storage$}{::Deploy}; | |||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 0 | DBIO::Util::assert_class_name($deploy_class); | |||||||||||||||||||||||||||
| 91 | 0 | ▶ | DBIO::Exception->throw( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 92 | "Cannot find native deploy class for storage $driver_class " | ||||||||||||||||||||||||||||
| 93 | . "(tried $deploy_class). Set dbio_deploy_class on the storage, or " | ||||||||||||||||||||||||||||
| 94 | . "provide a native Deploy class at $deploy_class." | ||||||||||||||||||||||||||||
| 95 | ) unless eval "require $deploy_class; 1"; | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | 0 | return $deploy_class->new(schema => $self->schema); | |||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 3 | 1; | |||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | # vim: ts=2 sw=2 expandtab | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | __END__ | ||||||||||||||||||||||||||||