« DeploymentHandler/WithReasonableDefaults.pm
↑ Summary
DeploymentHandler/VersionStorage/Standard/Component.pm »
| 1 | package DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 19 | $DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator::VERSION = '0.002235'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 19 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # ABSTRACT: Manage your SQL and Perl migrations in nicely laid out directories | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 19 | ▶ | use autodie; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 19 | ▶ | use Carp qw( carp croak ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 19 | ▶ | use DBIx::Class::DeploymentHandler::LogImporter qw(:log :dlog); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 19 | ▶ | use Context::Preserve; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 19 | ▶ | use Digest::MD5; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 19 | ▶ | use Try::Tiny; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 19 | ▶ | use SQL::SplitStatement '1.00020'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 19 | ▶ | use SQL::Translator; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 19 | require SQL::Translator::Diff; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 19 | require DBIx::Class::Storage; # loaded for type constraint | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 19 | ▶ | use DBIx::Class::DeploymentHandler::Types; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 19 | ▶ | use Path::Class qw(file dir); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 19 | with 'DBIx::Class::DeploymentHandler::HandlesDeploy'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 19 | has ignore_ddl => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | isa => 'Bool', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | default => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 19 | has force_overwrite => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | isa => 'Bool', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | default => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 19 | has schema => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | required => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 19 | has storage => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | isa => 'DBIx::Class::Storage', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | lazy_build => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 19 | has version_source => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | default => '__VERSION', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 45 | ▶ | sub _build_storage { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_storage: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 45 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 45 | my $s = $self->schema->storage; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 45 | $s->_determine_driver; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 45 | $s | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | has sql_translator_args => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | isa => 'HashRef', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 26 | ▶ | default => sub { {} }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 19 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 19 | has script_directory => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | required => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | default => 'sql', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | has databases => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | coerce => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | isa => 'DBIx::Class::DeploymentHandler::Databases', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 1 | ▶ | default => sub { [qw( MySQL SQLite PostgreSQL )] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 19 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 19 | has txn_prep => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | isa => 'Bool', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | default => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 19 | has txn_wrap => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | isa => 'Bool', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | default => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 19 | has schema_version => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | lazy_build => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | # this will probably never get called as the DBICDH | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | # will be passing down a schema_version normally, which | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | # is built the same way, but we leave this in place | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 13 | ▶ | sub _build_schema_version { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_schema_version: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 13 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 13 | $self->schema->schema_version | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 19 | has sql_splitter => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | builder => '_build_sql_splitter', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 51 | ▶ | sub _build_sql_splitter { SQL::SplitStatement->new } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_sql_splitter: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 47 | ▶ | sub __ddl_consume_with_prefix { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ddl_consume_with_prefix: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 47 | my ($self, $type, $versions, $prefix) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 47 | my $base_dir = $self->script_directory; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 47 | my $main = dir( $base_dir, $type ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | my $common = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 47 | dir( $base_dir, '_common', $prefix, join q(-), @{$versions} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 47 | my $common_any = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | dir( $base_dir, '_common', $prefix, '_any' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 47 | my $dir_any = dir($main, $prefix, '_any'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 47 | my %files; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 47 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 47 | my $dir = dir( $main, $prefix, join q(-), @{$versions} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 47 | opendir my($dh), $dir; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | %files = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 46 | map { $_ => "$dir/$_" } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 37 | ▶ | grep { /\.(?:sql|pl|sql-\w+)$/ && -f "$dir/$_" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
/\.(?:sql|pl|sql-\w+)$/ && -f "$dir/$_"
MC/DC50%1/2
/\.(?:sql|pl|sql-\w+)$/ && -f "$dir/$_"
/\.(?:sql|pl|sql-\w+)$/
-f "$dir/$_"
Truth table66%2/3
A && B
A= /\.(?:sql|pl|sql-\w+)$/B= -f "$dir/$_"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | readdir $dh; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 37 | closedir $dh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 10 | ▶ | } catch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 10 | ▶ | die $_ unless $self->ignore_ddl; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 47 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 47 | for my $dirname (grep { -d $_ } $common, $common_any, $dir_any) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 17 | opendir my($dh), $dirname; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 17 | ▶ | for my $filename (grep { /\.(?:sql|pl)$/ && -f file($dirname,$_) } readdir $dh) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
/\.(?:sql|pl)$/ && -f file($dirname, $_)
MC/DC50%1/2
/\.(?:sql|pl)$/ && -f file($dirname, $_)
/\.(?:sql|pl)$/
-f file($dirname, $_)
Truth table66%2/3
A && B
A= /\.(?:sql|pl)$/B= -f file($dirname, $_)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 19 | ▶ | unless ($files{$filename}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 19 | $files{$filename} = file($dirname,$filename); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 17 | closedir $dh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 47 | return [@files{sort keys %files}] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 2 | ▶ | sub _ddl_initialize_consume_filenames { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ddl_initialize_consume_filenames: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 2 | my ($self, $type, $version) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 2 | $self->__ddl_consume_with_prefix($type, [ $version ], 'initialize') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 16 | ▶ | sub _ddl_schema_consume_filenames { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ddl_schema_consume_filenames: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 16 | my ($self, $type, $version) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 16 | $self->__ddl_consume_with_prefix($type, [ $version ], 'deploy') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 3 | ▶ | sub _ddl_protoschema_deploy_consume_filenames { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ddl_protoschema_deploy_consume_filenames: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 3 | my ($self, $version) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 3 | my $base_dir = $self->script_directory; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 3 | my $dir = dir( $base_dir, '_source', 'deploy', $version); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 3 | ▶ | return [] unless -d $dir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 2 | opendir my($dh), $dir; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 2 | ▶ | my %files = map { $_ => "$dir/$_" } grep { /\.yml$/ && -f "$dir/$_" } readdir $dh; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
/\.yml$/ && -f "$dir/$_"
MC/DC50%1/2
/\.yml$/ && -f "$dir/$_"
/\.yml$/
-f "$dir/$_"
Truth table66%2/3
A && B
A= /\.yml$/B= -f "$dir/$_"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 2 | closedir $dh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 2 | return [@files{sort keys %files}] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 21 | ▶ | sub _ddl_protoschema_upgrade_consume_filenames { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ddl_protoschema_upgrade_consume_filenames: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 21 | my ($self, $versions) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 21 | my $base_dir = $self->script_directory; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 21 | my $dir = dir( $base_dir, '_preprocess_schema', 'upgrade', join q(-), @{$versions}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 21 | ▶ | return [] unless -d $dir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 1 | opendir my($dh), $dir; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 1 | ▶ | my %files = map { $_ => "$dir/$_" } grep { /\.pl$/ && -f "$dir/$_" } readdir $dh; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
/\.pl$/ && -f "$dir/$_"
MC/DC50%1/2
/\.pl$/ && -f "$dir/$_"
/\.pl$/
-f "$dir/$_"
Truth table66%2/3
A && B
A= /\.pl$/B= -f "$dir/$_"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 1 | closedir $dh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 1 | return [@files{sort keys %files}] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 9 | ▶ | sub _ddl_protoschema_downgrade_consume_filenames { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ddl_protoschema_downgrade_consume_filenames: called CC=3 SCAR=16.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 9 | my ($self, $versions) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 9 | my $base_dir = $self->script_directory; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 9 | my $dir = dir( $base_dir, '_preprocess_schema', 'downgrade', join q(-), @{$versions}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 9 | ▶ | return [] unless -d $dir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | opendir my($dh), $dir; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | my %files = map { $_ => "$dir/$_" } grep { /\.pl$/ && -f "$dir/$_" } readdir $dh; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
/\.pl$/ && -f "$dir/$_"
MC/DC0%0/2
/\.pl$/ && -f "$dir/$_"
/\.pl$/
-f "$dir/$_"
Truth table0%0/3
A && B
A= /\.pl$/B= -f "$dir/$_"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | closedir $dh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | return [@files{sort keys %files}] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 119 | ▶ | sub _ddl_protoschema_produce_filename { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ddl_protoschema_produce_filename: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 119 | my ($self, $version) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 119 | my $dirname = dir( $self->script_directory, '_source', 'deploy', $version ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 119 | ▶ | $dirname->mkpath unless -d $dirname; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 119 | return "" . file( $dirname, '001-auto.yml' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 21 | ▶ | sub _ddl_schema_produce_filename { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ddl_schema_produce_filename: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 21 | my ($self, $type, $version) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 21 | my $dirname = dir( $self->script_directory, $type, 'deploy', $version ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 21 | ▶ | $dirname->mkpath unless -d $dirname; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 21 | return "" . file( $dirname, '001-auto.sql' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 21 | ▶ | sub _ddl_schema_upgrade_consume_filenames { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ddl_schema_upgrade_consume_filenames: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 21 | my ($self, $type, $versions) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 21 | $self->__ddl_consume_with_prefix($type, $versions, 'upgrade') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 8 | ▶ | sub _ddl_schema_downgrade_consume_filenames { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ddl_schema_downgrade_consume_filenames: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 8 | my ($self, $type, $versions) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 8 | $self->__ddl_consume_with_prefix($type, $versions, 'downgrade') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 18 | ▶ | sub _ddl_schema_upgrade_produce_filename { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ddl_schema_upgrade_produce_filename: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 18 | my ($self, $type, $versions) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 18 | my $dir = $self->script_directory; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 18 | my $dirname = dir( $dir, $type, 'upgrade', join q(-), @{$versions}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 18 | ▶ | $dirname->mkpath unless -d $dirname; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 18 | return "" . file( $dirname, '001-auto.sql' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 6 | ▶ | sub _ddl_schema_downgrade_produce_filename { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ddl_schema_downgrade_produce_filename: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 6 | my ($self, $type, $versions, $dir) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 6 | my $dirname = dir( $dir, $type, 'downgrade', join q(-), @{$versions} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 6 | ▶ | $dirname->mkpath unless -d $dirname; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 6 | return "" . file( $dirname, '001-auto.sql'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 61 | ▶ | sub _run_sql_array { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_run_sql_array: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 61 | my ($self, $sql) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 61 | my $storage = $self->storage; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 61 | $sql = [ $self->_split_sql_chunk( @$sql ) ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | ▶ | Dlog_trace { "Running SQL $_" } $sql; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 61 | foreach my $line (@{$sql}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 116 | $storage->_query_start($line); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | # the whole reason we do this is so that we can see the line that was run | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 116 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 116 | ▶ | $storage->dbh_do (sub { $_[1]->do($line) }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 3 | ▶ | catch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 3 | die "$_ (running line '$line')" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 116 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 113 | $storage->_query_end($line); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 58 | return join "\n", @$sql | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 19 | my %TXN = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | SQLServer => qr/(BEGIN\s+TRANSACTION\b|COMMIT\b)/i, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | Sybase => qr/(BEGIN\s+TRANSACTION\b|COMMIT\b)/i, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | SQLite => qr/(BEGIN\b|COMMIT\b)/i, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | mysql => qr/(BEGIN\b|START\s+TRANSACTION\b|COMMIT\b)/i, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | Oracle => qr/COMMIT\b/i, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | Pg => qr/(BEGIN\b|COMMIT\b)/i, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 119 | ▶ | sub _split_sql_chunk { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_split_sql_chunk: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 119 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 119 | my ($storage_class) = ref($self->storage) =~ /.*:(\w+)$/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 119 | ▶ | my $txn = $TXN{$storage_class} || $TXN{mysql}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$TXN{$storage_class} || $TXN{'mysql'}
MC/DC0%0/2
$TXN{$storage_class} || $TXN{'mysql'}
$TXN{$storage_class}
$TXN{'mysql'}
Truth table33%1/3
A || B
A= $TXN{$storage_class}B= $TXN{'mysql'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | # MySQL's DELIMITER is not understood by the server but handled on the client. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | # SQL::SplitStatement treats the statements between the DELIMITERs correctly | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | # as ONE statement - but it does not remove the DELIMITER lines. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | # https://rt.cpan.org/Public/Bug/Display.html?id=130473 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | # Transaction statements should not be present if txn_prep is false, if it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | # is true then anything that looks like a transaction is removed here. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | my @sql = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | grep { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 336 | ▶ | ($storage_class ne 'mysql' || /^(?!DELIMITER\s+)/i) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%9/9
($storage_class ne 'mysql' || /^(?!DELIMITER\s+)/i) && (!$self->txn_prep || /^(?!$txn)/mig)
$storage_class ne "mysql" or /^(?!DELIMITER\s+)/i
not $self->txn_prep or /^(?!$txn)/mig
MC/DC100%4/4
($storage_class ne 'mysql' || /^(?!DELIMITER\s+)/i) && (!$self->txn_prep || /^(?!$txn)/mig)
$storage_class ne "mysql"
/^(?!DELIMITER\s+)/i
not $self->txn_prep
/^(?!$txn)/mig
Truth table100%7/7
A or B && not(C) or D
A= $storage_class ne "mysql"B= /^(?!DELIMITER\s+)/iC= not $self->txn_prepD= /^(?!$txn)/mig
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | (!$self->txn_prep || /^(?!$txn)/gim) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 119 | $self->sql_splitter->split($_) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | } @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 119 | for ( @sql ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 218 | s/\s*\n+\s*/ /g; # put on single line | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 119 | return @sql; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 51 | ▶ | sub _run_sql { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_run_sql: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 51 | my ($self, $filename) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | log_debug { "Running SQL from $filename" }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 51 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 51 | $self->_run_sql_array($self->_read_sql_file($filename)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 3 | ▶ | } catch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 3 | die "failed to run SQL in $filename: $_" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 51 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 19 | my ( %f2p, %p2f ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 17 | ▶ | sub _generate_script_package_name { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_script_package_name: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 17 | my $file = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 17 | my $pkgbase = 'DBICDH::Sandbox::'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 17 | my $maxlen = 200; # actual limit is "about 250" according to perldiag | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 17 | ▶ | return $pkgbase . $f2p{"$file"} if $f2p{"$file"}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 10 | my $package = Digest::MD5::md5_hex("$file"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 10 | ▶ | $package++ while exists $p2f{$package}; # increment until unique | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 10 | ▶ | die "unable to generate a unique short name for '$file'" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | if length($pkgbase) + length($package) > $maxlen; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 10 | $f2p{"$file"} = $package; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 10 | $p2f{$package} = "$file"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 10 | return $pkgbase . $package; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 17 | ▶ | sub _load_sandbox { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_load_sandbox: called CC=4 SCAR=14.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 17 | my $_file = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 17 | $_file = "$_file"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 17 | my $_package = _generate_script_package_name($_file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 17 | my $fn = eval sprintf <<'END_EVAL', $_package; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | package %s; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | our $app; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | $app ||= do $_file; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | if ( !$app && ( my $error = $@ || $! )) { die $error; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | $app; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | END_EVAL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 17 | ▶ | croak $@ if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 17 | ▶ | croak "$_file should define an anonymous sub that takes a schema but it didn't!" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $fn and ref $fn eq "CODE"
MC/DC0%0/2
ref $fn and ref $fn eq "CODE"
ref $fn
ref $fn eq "CODE"
Truth table33%1/3
A and B
A= ref $fnB= ref $fn eq "CODE"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | unless ref $fn && ref $fn eq 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 17 | return $fn; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 17 | ▶ | sub _run_perl { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_run_perl: called CC=1 SCAR=0.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 17 | my ($self, $filename, $versions) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | ▶ | log_debug { "Running Perl from $filename" }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 17 | my $fn = _load_sandbox($filename); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | ▶ | Dlog_trace { "Running Perl $_" } $fn; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 17 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 17 | $fn->($self->schema, $versions) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 2 | ▶ | } catch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 2 | die "failed to run Perl in $filename: $_" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 17 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 83 | ▶ | sub txn_do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
txn_do: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 83 | my ( $self, $code ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 83 | ▶ | return $code->() unless $self->txn_wrap; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 73 | my $guard = $self->schema->txn_scope_guard; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 73 | ▶ | return preserve_context { $code->() } after => sub { $guard->commit }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 49 | ▶ | sub _run_sql_and_perl { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_run_sql_and_perl: called CC=1 SCAR=0.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 49 | my ($self, $filenames, $sql_to_run, $versions) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 49 | my @files = @{$filenames}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 49 | ▶ | $self->txn_do(sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=8 SCAR=21.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 49 | ▶ | $self->_run_sql_array($sql_to_run) if $self->ignore_ddl; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 49 | ▶ | my $sql = ($sql_to_run)?join ";\n", @$sql_to_run:''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | FILENAME: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 49 | for my $filename (map file($_), @files) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 66 | ▶ | if ($self->ignore_ddl && $filename->basename =~ /^[^-]*-auto.*\.sql$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition66%2/3
$self->ignore_ddl and $filename->basename =~ /^[^-]*-auto.*\.sql$/
MC/DC0%0/2
$self->ignore_ddl and $filename->basename =~ /^[^-]*-auto.*\.sql$/
$self->ignore_ddl
$filename->basename =~ /^[^-]*-auto.*\.sql$/
Truth table66%2/3
A and B
A= $self->ignore_ddlB= $filename->basename =~ /^[^-]*-auto.*\.sql$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | next FILENAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | } elsif ($filename =~ /\.sql$/) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 51 | $sql .= $self->_run_sql($filename) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | } elsif ( $filename =~ /\.pl$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 15 | $self->_run_perl($filename, $versions) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | croak "A file ($filename) got to deploy that wasn't sql or perl!"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 45 | return $sql; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 49 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 18 | ▶ | sub deploy { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
deploy: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 18 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 18 | ▶ | my $version = (shift @_ || {})->{version} || $self->schema_version; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition80%4/5
+(shift @_ || {})->{'version'} || $self->schema_version
shift @_ || {}
MC/DC0%0/2
+(shift @_ || {})->{'version'} || $self->schema_version
shift @_
$self->schema_version
Truth table66%2/3
A || B
A= shift @_B= $self->schema_version
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | ▶ | log_info { "deploying version $version" }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 18 | my $sqlt_type = $self->storage->sqlt_type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 18 | my $sql; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 18 | my $sqltargs = $self->sql_translator_args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 18 | ▶ | if ($self->ignore_ddl) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 3 | $sql = $self->_sql_from_yaml($sqltargs, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | '_ddl_protoschema_deploy_consume_filenames', $sqlt_type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 18 | return $self->_run_sql_and_perl($self->_ddl_schema_consume_filenames( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | $sqlt_type, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | $version, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | ), $sql, [$version]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 2 | ▶ | sub initialize { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
initialize: called CC=7 SCAR=20.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 2 | my $args = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 2 | ▶ | my $version = $args->{version} || $self->schema_version; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$args->{'version'} || $self->schema_version
MC/DC0%0/2
$args->{'version'} || $self->schema_version
$args->{'version'}
$self->schema_version
Truth table33%1/3
A || B
A= $args->{'version'}B= $self->schema_version
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | ▶ | log_info { "initializing version $version" }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 2 | ▶ | my $storage_type = $args->{storage_type} || $self->storage->sqlt_type; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$args->{'storage_type'} || $self->storage->sqlt_type
MC/DC0%0/2
$args->{'storage_type'} || $self->storage->sqlt_type
$args->{'storage_type'}
$self->storage->sqlt_type
Truth table66%2/3
A || B
A= $args->{'storage_type'}B= $self->storage->sqlt_type
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 2 | my @files = @{$self->_ddl_initialize_consume_filenames( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | $storage_type, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | $version, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | )}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 2 | for my $filename (@files) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | # We ignore sql for now (till I figure out what to do with it) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 3 | ▶ | if ( $filename =~ /^(.+)\.pl$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 3 | my $filedata = do { local( @ARGV, $/ ) = $filename; <> }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 19 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 3 | ▶ | my $fn = eval "$filedata"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 19 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 3 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | croak "$filename failed to compile: $@"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | } elsif (ref $fn eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 3 | $fn->() | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | croak "$filename should define an anonymous sub but it didn't!"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | croak "A file ($filename) got to initialize_scripts that wasn't sql or perl!"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 30 | ▶ | sub _sqldiff_from_yaml { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_sqldiff_from_yaml: called CC=12 SCAR=25.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 30 | my ($self, $from_version, $to_version, $db, $direction) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 30 | my $dir = $self->script_directory; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | my $sqltargs = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | add_drop_table => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | ignore_constraint_names => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | ignore_index_names => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 30 | %{$self->sql_translator_args} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 30 | my $source_schema; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 30 | my $prefilename = $self->_ddl_protoschema_produce_filename($from_version, $dir); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | # should probably be a croak | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 30 | ▶ | carp("No previous schema file found ($prefilename)") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | unless -e $prefilename; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | my $t = SQL::Translator->new({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 30 | %{$sqltargs}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | debug => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | trace => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | parser => 'SQL::Translator::Parser::YAML', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 30 | ▶ | my $out = $t->translate( $prefilename ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | or croak($t->error); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 30 | $source_schema = $t->schema; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 30 | ▶ | $source_schema->name( $prefilename ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | unless $source_schema->name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 30 | my $dest_schema; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 30 | my $filename = $self->_ddl_protoschema_produce_filename($to_version, $dir); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | # should probably be a croak | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 30 | ▶ | carp("No next schema file found ($filename)") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | unless -e $filename; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | my $t = SQL::Translator->new({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 30 | %{$sqltargs}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | debug => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | trace => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | parser => 'SQL::Translator::Parser::YAML', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 30 | ▶ | my $out = $t->translate( $filename ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | or croak($t->error); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 30 | $dest_schema = $t->schema; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 30 | ▶ | $dest_schema->name( $filename ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | unless $dest_schema->name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 30 | my $transform_files_method = "_ddl_protoschema_${direction}_consume_filenames"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 30 | my $transforms = $self->_coderefs_per_files( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | $self->$transform_files_method([$from_version, $to_version]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 30 | $_->($source_schema, $dest_schema) for @$transforms; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | # SQL::Translator::Diff::schema_diff or rather the underlying | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | # SQL::Translator::Diff::produce_diff_sql has severe issues: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | # 1. It is undocumented | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | # 2. It wraps the result in "BEGIN; ... COMMIT;" *SIGH* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | # 3. In a first glance it seems it could also return undef in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | # list context, but the code is broken enough so that part | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | # is never reached. *roll eyes* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 30 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 30 | my @stmts = SQL::Translator::Diff::schema_diff( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | $source_schema, $db, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | $dest_schema, $db, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | { sqlt_args => $sqltargs } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 30 | ▶ | if (!$self->txn_prep && $self->txn_wrap) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $self->txn_prep and $self->txn_wrap
MC/DC50%1/2
not $self->txn_prep and $self->txn_wrap
not $self->txn_prep
$self->txn_wrap
Truth table66%2/3
not(A) and B
A= not $self->txn_prepB= $self->txn_wrap
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 1 | pop @stmts; # remove final COMMIT | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 1 | ▶ | ++$i while $stmts[$i] =~ /^-- /; # skip leading comments | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 1 | ▶ | splice @stmts, $i, 1 if $stmts[$i] =~ /^BEGIN;/; # remove first BEGIN; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 30 | return \@stmts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 47 | ▶ | sub _sql_from_yaml { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_sql_from_yaml: called CC=4 SCAR=14.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 47 | my ($self, $sqltargs, $from_file, $db) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 47 | my $schema = $self->schema; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 47 | my $version = $self->schema_version; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 47 | my @sql; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 47 | my $actual_file = $self->$from_file($version); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 47 | for my $yaml_filename (@{( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | ▶ | DlogS_trace { "generating SQL from Serialized SQL Files: $_" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 47 | ▶ | (ref $actual_file?$actual_file:[$actual_file]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | )}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | my $sqlt = SQL::Translator->new({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | add_drop_table => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | parser => 'SQL::Translator::Parser::YAML', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 48 | %{$sqltargs}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | producer => $db, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 48 | push @sql, $sqlt->translate($yaml_filename); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 48 | ▶ | if(!@sql) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | carp("Failed to translate to $db, skipping. (" . $sqlt->error . ")"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 47 | return \@sql; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 56 | ▶ | sub _prepare_install { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_prepare_install: called CC=5 SCAR=17.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 56 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 56 | my $sqltargs = { %{$self->sql_translator_args}, %{shift @_} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 56 | my $from_file = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 56 | my $to_file = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 56 | my $dir = $self->script_directory; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 56 | my $databases = $self->databases; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 56 | my $version = $self->schema_version; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 56 | foreach my $db (@$databases) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 44 | ▶ | my $sql = $self->_sql_from_yaml($sqltargs, $from_file, $db ) or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 44 | my $filename = $self->$to_file($db, $version, $dir); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 44 | ▶ | if (-e $filename ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 0 | ▶ | if ($self->force_overwrite) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | carp "Overwriting existing DDL file - $filename"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | unlink $filename; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | die "Cannot overwrite '$filename', either enable force_overwrite or delete it" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 44 | open my $file, q(>), $filename; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 44 | binmode $file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 44 | print {$file} join ";\n", @$sql, ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 44 | close $file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 26 | ▶ | sub _resultsource_install_filename { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_resultsource_install_filename: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 26 | my ($self, $source_name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 20 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 20 | my ($self, $type, $version) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 20 | my $dirname = dir( $self->script_directory, $type, 'deploy', $version ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 20 | ▶ | $dirname->mkpath unless -d $dirname; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 20 | return "" . file( $dirname, "001-auto-$source_name.sql" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 26 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 24 | ▶ | sub _resultsource_protoschema_filename { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_resultsource_protoschema_filename: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 24 | my ($self, $source_name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 42 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 42 | my ($self, $version) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 42 | my $dirname = dir( $self->script_directory, '_source', 'deploy', $version ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 42 | ▶ | $dirname->mkpath unless -d $dirname; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 42 | return "" . file( $dirname, "001-auto-$source_name.yml" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 24 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 2 | ▶ | sub install_resultsource { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
install_resultsource: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 2 | my ($self, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | my $source = $args->{result_source} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 2 | ▶ | or die 'result_source must be passed to install_resultsource'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | my $version = $args->{version} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 2 | ▶ | or die 'version must be passed to install_resultsource'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 0 | ▶ | log_info { 'installing_resultsource ' . $source->source_name . ", version $version" }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 2 | my $rs_install_file = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | $self->_resultsource_install_filename($source->source_name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 2 | my $files = [ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | $self->$rs_install_file( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | $self->storage->sqlt_type, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | $version, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 2 | $self->_run_sql_and_perl($files, [], [$version]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 24 | ▶ | sub prepare_resultsource_install { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prepare_resultsource_install: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 24 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 24 | my $source = (shift @_)->{result_source}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 0 | ▶ | log_info { 'preparing install for resultsource ' . $source->source_name }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 24 | my $install_filename = $self->_resultsource_install_filename($source->source_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 24 | my $proto_filename = $self->_resultsource_protoschema_filename($source->source_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 24 | $self->prepare_protoschema({ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | parser_args => { sources => [$source->source_name], } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | }, $proto_filename); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 24 | $self->_prepare_install({}, $proto_filename, $install_filename); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 33 | ▶ | sub prepare_deploy { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prepare_deploy: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 0 | ▶ | log_info { 'preparing deploy' }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 33 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | $self->prepare_protoschema({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | # Exclude version table so that it gets installed separately | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | parser_args => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | sources => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 3 | sort { $a cmp $b } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 33 | grep { $_ ne $self->version_source } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | $self->schema->sources | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | }, '_ddl_protoschema_produce_filename'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 32 | $self->_prepare_install({}, '_ddl_protoschema_produce_filename', '_ddl_schema_produce_filename'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 18 | ▶ | sub prepare_upgrade { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prepare_upgrade: called CC=1 SCAR=0.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 18 | my ($self, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 0 | ▶ | log_info { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 0 | "preparing upgrade from $args->{from_version} to $args->{to_version}" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 18 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | $self->_prepare_changegrade( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 18 | $args->{from_version}, $args->{to_version}, $args->{version_set}, 'upgrade' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 6 | ▶ | sub prepare_downgrade { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prepare_downgrade: called CC=1 SCAR=0.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 6 | my ($self, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 0 | ▶ | log_info { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 0 | "preparing downgrade from $args->{from_version} to $args->{to_version}" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 6 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | $self->_prepare_changegrade( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 6 | $args->{from_version}, $args->{to_version}, $args->{version_set}, 'downgrade' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 30 | ▶ | sub _coderefs_per_files { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_coderefs_per_files: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 30 | my ($self, $files) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 19 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 30 | [map eval do { local( @ARGV, $/ ) = $_; <> }, @$files] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 24 | ▶ | sub _prepare_changegrade { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_prepare_changegrade: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 24 | my ($self, $from_version, $to_version, $version_set, $direction) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 24 | my $schema = $self->schema; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 24 | my $databases = $self->databases; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 24 | my $dir = $self->script_directory; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 24 | my $schema_version = $self->schema_version; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 24 | my $diff_file_method = "_ddl_schema_${direction}_produce_filename"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | 24 | foreach my $db (@$databases) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 24 | my $diff_file = $self->$diff_file_method($db, $version_set, $dir ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 24 | ▶ | if(-e $diff_file) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 1 | ▶ | if ($self->force_overwrite) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 0 | carp("Overwriting existing $direction-diff file - $diff_file"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 0 | unlink $diff_file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 1 | die "Cannot overwrite '$diff_file', either enable force_overwrite or delete it" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 23 | open my $file, q(>), $diff_file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 23 | binmode $file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 23 | print {$file} join ";\n", @{$self->_sqldiff_from_yaml($from_version, $to_version, $db, $direction)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 23 | close $file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | 51 | ▶ | sub _read_sql_file { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_read_sql_file: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 51 | my ($self, $file) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | 51 | ▶ | return unless $file; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 51 | local $/ = undef; #sluuuuuurp | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 51 | open my $fh, '<', $file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 51 | return [ $self->_split_sql_chunk( <$fh> ) ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 8 | ▶ | sub downgrade_single_step { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
downgrade_single_step: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 8 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 8 | my $version_set = (shift @_)->{version_set}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 0 | ▶ | Dlog_info { "downgrade_single_step'ing $_" } $version_set; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 8 | my $sqlt_type = $self->storage->sqlt_type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 8 | my $sql_to_run; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 8 | ▶ | if ($self->ignore_ddl) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 3 | $sql_to_run = $self->_sqldiff_from_yaml( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | $version_set->[0], $version_set->[1], $sqlt_type, 'downgrade', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 8 | my $sql = $self->_run_sql_and_perl($self->_ddl_schema_downgrade_consume_filenames( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | $sqlt_type, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | $version_set, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | ), $sql_to_run, $version_set); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 8 | return ['', $sql]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 21 | ▶ | sub upgrade_single_step { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
upgrade_single_step: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | 21 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 21 | my $version_set = (shift @_)->{version_set}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | 0 | ▶ | Dlog_info { "upgrade_single_step'ing $_" } $version_set; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | 21 | my $sqlt_type = $self->storage->sqlt_type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | 21 | my $sql_to_run; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 21 | ▶ | if ($self->ignore_ddl) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 4 | $sql_to_run = $self->_sqldiff_from_yaml( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | $version_set->[0], $version_set->[1], $sqlt_type, 'upgrade', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 21 | my $sql = $self->_run_sql_and_perl($self->_ddl_schema_upgrade_consume_filenames( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | $sqlt_type, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | $version_set, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | ), $sql_to_run, $version_set); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 20 | return ['', $sql]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | 57 | ▶ | sub prepare_protoschema { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prepare_protoschema: called CC=4 SCAR=14.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 57 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 57 | my $sqltargs = { %{$self->sql_translator_args}, %{shift @_} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 57 | my $to_file = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 57 | my $filename | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | = $self->$to_file($self->schema_version); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | # we do this because the code that uses this sets parser args, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | # so we just need to merge in the package | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | my $sqlt = SQL::Translator->new({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | parser => 'SQL::Translator::Parser::DBIx::Class', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | producer => 'SQL::Translator::Producer::YAML', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 57 | %{ $sqltargs }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 57 | my $yml = $sqlt->translate(data => $self->schema); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | 57 | ▶ | croak("Failed to translate to YAML: " . $sqlt->error) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | unless $yml; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | 57 | ▶ | if (-e $filename ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 1 | ▶ | if ($self->force_overwrite) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | 0 | carp "Overwriting existing DDL-YML file - $filename"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 0 | unlink $filename; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | 1 | die "Cannot overwrite '$filename', either enable force_overwrite or delete it" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | 56 | open my $file, q(>), $filename; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 56 | binmode $file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 56 | print {$file} $yml; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | 56 | close $file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | 19 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | 19 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | # vim: ts=2 sw=2 expandtab | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||