From: Arthur Axel 'fREW' Schmidt Date: Thu, 27 May 2010 23:59:12 +0000 (-0500) Subject: warn when people try to upgrade w/o needing to X-Git-Tag: v0.001000_12~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4355e4fb0c11c32c5fa81cf2428203bd6640f024;p=dbsrgits%2FDBIx-Class-DeploymentHandler.git warn when people try to upgrade w/o needing to --- diff --git a/lib/DBIx/Class/DeploymentHandler/Dad.pm b/lib/DBIx/Class/DeploymentHandler/Dad.pm index 093904e..aedd707 100644 --- a/lib/DBIx/Class/DeploymentHandler/Dad.pm +++ b/lib/DBIx/Class/DeploymentHandler/Dad.pm @@ -56,7 +56,9 @@ method install { sub upgrade { log_info { '[DBICDH] upgrading' }; my $self = shift; + my $ran_once = 0; while ( my $version_list = $self->next_version_set ) { + $ran_once = 1; my ($ddl, $upgrade_sql) = @{ $self->upgrade_single_step({ version_set => $version_list }) ||[]}; @@ -67,17 +69,22 @@ sub upgrade { upgrade_sql => $upgrade_sql, }); } + + log_warn { '[DBICDH] no need to run upgrade' } unless $ran_once; } sub downgrade { log_info { '[DBICDH] upgrading' }; my $self = shift; + my $ran_once = 0; while ( my $version_list = $self->previous_version_set ) { + $ran_once = 1; $self->downgrade_single_step({ version_set => $version_list }); # do we just delete a row here? I think so but not sure $self->delete_database_version({ version => $version_list->[-1] }); } + log_warn { '[DBICDH] no version to run downgrade' } unless $ran_once; } method backup { diff --git a/lib/DBIx/Class/DeploymentHandler/Logger.pm b/lib/DBIx/Class/DeploymentHandler/Logger.pm new file mode 100644 index 0000000..8112717 --- /dev/null +++ b/lib/DBIx/Class/DeploymentHandler/Logger.pm @@ -0,0 +1,32 @@ +package DBIx::Class::DeploymentHandler::Logger; + +use warnings; +use strict; + +use parent 'Log::Contextual::WarnLogger'; + +# trace works the way we want it already + +# sub is_trace { $_[0]->next::method } +sub is_debug { $_[0]->is_trace || $_[0]->next::method } +sub is_info { $_[0]->is_debug || $_[0]->next::method } + +sub is_warn { + my $orig = $_[0]->next::method; + return undef if defined $orig && !$orig; + return $_[0]->is_info || 1 +} + +sub is_error { + my $orig = $_[0]->next::method; + return undef if defined $orig && !$orig; + return $_[0]->is_warn || 1 +} + +sub is_fatal { + my $orig = $_[0]->next::method; + return undef if defined $orig && !$orig; + return $_[0]->is_error || 1 +} + +1;