use Method::Signatures::Simple;
require DBIx::Class::Schema; # loaded for type constraint
use Carp::Clan '^DBIx::Class::DeploymentHandler';
+use Log::Contextual::WarnLogger;
+use Log::Contextual ':log', -default_logger => Log::Contextual::WarnLogger->new({
+ env_prefix => 'DBICDH'
+});
has schema => (
isa => 'DBIx::Class::Schema',
sub _build_schema_version { $_[0]->schema->schema_version }
method install {
+ log_info { '[DBICDH] installing version ' . $self->to_version };
croak 'Install not possible as versions table already exists in database'
if $self->version_storage_is_installed;
}
sub upgrade {
+ log_info { '[DBICDH] upgrading' };
my $self = shift;
while ( my $version_list = $self->next_version_set ) {
my ($ddl, $upgrade_sql) = @{
}
sub downgrade {
+ log_info { '[DBICDH] upgrading' };
my $self = shift;
while ( my $version_list = $self->previous_version_set ) {
$self->downgrade_single_step({ version_set => $version_list });
}
}
-method backup { $self->storage->backup($self->backup_directory) }
+method backup {
+ log_info { '[DBICDH] backing up' };
+ $self->storage->backup($self->backup_directory)
+}
__PACKAGE__->meta->make_immutable;
use autodie;
use Carp qw( carp croak );
+use Log::Contextual::WarnLogger;
+use Log::Contextual qw(:log :dlog), -default_logger => Log::Contextual::WarnLogger->new({
+ env_prefix => 'DBICDH'
+});
+use Data::Dumper::Concise;
use Method::Signatures::Simple;
use Try::Tiny;
my $sql;
for my $filename (@files) {
if ($filename =~ /\.sql$/) {
+ log_debug { "[DBICDH] Running SQL from $filename" };
my @sql = @{$self->_read_sql_file($filename)};
$sql .= join "\n", @sql;
+ log_trace { "[DBICDH] Running SQL $sql" };
foreach my $line (@sql) {
$storage->_query_start($line);
$storage->_query_end($line);
}
} elsif ( $filename =~ /^(.+)\.pl$/ ) {
+ log_debug { "[DBICDH] Running Perl from $filename" };
my $filedata = do { local( @ARGV, $/ ) = $filename; <> };
no warnings 'redefine';
my $fn = eval "$filedata";
use warnings;
+ log_trace { '[DBICDH] Running Perl ' . Dumper($fn) };
if ($@) {
carp "$filename failed to compile: $@";
sub deploy {
my $self = shift;
my $version = (shift @_ || {})->{version} || $self->schema_version;
+ log_info { "[DBICDH] deploying version $version" };
return $self->_run_sql_and_perl($self->_ddl_schema_consume_filenames(
$self->storage->sqlt_type,
my $self = shift;
my $args = shift;
my $version = $args->{version} || $self->schema_version;
+ log_info { "[DBICDH] preinstalling version $version" };
my $storage_type = $args->{storage_type} || $self->storage->sqlt_type;
my @files = @{$self->_ddl_preinstall_consume_filenames(
my ($self, $args) = @_;
my $source = $args->{result_source};
my $version = $args->{version};
+ log_info { '[DBICDH] installing_resultsource ' . $source->source_name . ", version $version" };
my $rs_install_file =
$self->_resultsource_install_filename($source->source_name);
sub prepare_resultsource_install {
my $self = shift;
my $source = (shift @_)->{result_source};
+ log_info { '[DBICDH] preparing install for resultsource ' . $source->source_name };
my $filename = $self->_resultsource_install_filename($source->source_name);
$self->_prepare_install({
}
sub prepare_deploy {
+ log_info { '[DBICDH] preparing deploy' };
my $self = shift;
$self->_prepare_install({}, '_ddl_schema_produce_filename');
}
sub prepare_upgrade {
my ($self, $args) = @_;
+ log_info {
+ '[DBICDH] preparing upgrade ' .
+ "from $args->{from_version} to $args->{to_version}"
+ };
$self->_prepare_changegrade(
$args->{from_version}, $args->{to_version}, $args->{version_set}, 'up'
);
sub prepare_downgrade {
my ($self, $args) = @_;
+ log_info {
+ '[DBICDH] preparing downgrade ' .
+ "from $args->{from_version} to $args->{to_version}"
+ };
$self->_prepare_changegrade(
$args->{from_version}, $args->{to_version}, $args->{version_set}, 'down'
);
sub downgrade_single_step {
my $self = shift;
my $version_set = (shift @_)->{version_set};
+ log_info { qq([DBICDH] downgrade_single_step'ing ) . Dumper($version_set) };
my $sql = $self->_run_sql_and_perl($self->_ddl_schema_down_consume_filenames(
$self->storage->sqlt_type,
sub upgrade_single_step {
my $self = shift;
my $version_set = (shift @_)->{version_set};
+ log_info { qq([DBICDH] upgrade_single_step'ing ) . Dumper($version_set) };
my $sql = $self->_run_sql_and_perl($self->_ddl_schema_up_consume_filenames(
$self->storage->sqlt_type,
package DBIx::Class::DeploymentHandler::VersionStorage::Deprecated;
use Moose;
+use Log::Contextual::WarnLogger;
+use Log::Contextual ':log', -default_logger => Log::Contextual::WarnLogger->new({
+ env_prefix => 'DBICDH'
+});
+
# ABSTRACT: (DEPRECATED) Use this if you are stuck in the past
sub add_database_version {
# deprecated doesn't support ddl or upgrade_ddl
- $_[0]->version_rs->create({ version => $_[1]->{version} })
+ my $version = $_[1]->{version};
+ log_debug { "[DBICDH] Adding database version $version" };
+ $_[0]->version_rs->create({ version => $version })
}
sub delete_database_version {
- $_[0]->version_rs->search({ version => $_[1]->{version}})->delete
+ my $version = $_[1]->{version};
+ log_debug { "[DBICDH] Deleting database version $version" };
+ $_[0]->version_rs->search({ version => $version})->delete
}
__PACKAGE__->meta->make_immutable;
package DBIx::Class::DeploymentHandler::VersionStorage::Standard;
use Moose;
+use Log::Contextual::WarnLogger;
+use Log::Contextual ':log', -default_logger => Log::Contextual::WarnLogger->new({
+ env_prefix => 'DBICDH'
+});
# ABSTRACT: Version storage that does the normal stuff
$_[0]->schema->resultset('__VERSION')
}
-sub add_database_version { $_[0]->version_rs->create($_[1]) }
+sub add_database_version {
+ my $version = $_[1]->{version};
+ log_debug { "[DBICDH] Adding database version $version" };
+ $_[0]->version_rs->create($_[1])
+}
sub delete_database_version {
- $_[0]->version_rs->search({ version => $_[1]->{version}})->delete
+ my $version = $_[1]->{version};
+ log_debug { "[DBICDH] Deleting database version $version" };
+ $_[0]->version_rs->search({ version => $version})->delete
}
__PACKAGE__->meta->make_immutable;