From: Yanick Champoux Date: Mon, 8 Aug 2011 16:23:23 +0000 (-0400) Subject: Stop deleting the wrong version X-Git-Tag: v0.001006~10 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2e3cccff896e3d8f98cfb3d1069be1c62cc24d69;p=dbsrgits%2FDBIx-Class-DeploymentHandler.git Stop deleting the wrong version If downgrading from 101 to 100, it'd try to delete version 100 from the database. --- diff --git a/Changes b/Changes index c9a9b92..89fe020 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,7 @@ Revision history for {{$dist->name}} {{$NEXT}} + - Stop deleting the wrong version - Fix documentation for in the Cookbook (moltar) 0.001005 2011-04-13 15:21:08 CST6CDT diff --git a/lib/DBIx/Class/DeploymentHandler/Dad.pm b/lib/DBIx/Class/DeploymentHandler/Dad.pm index 86043e8..1fb3520 100644 --- a/lib/DBIx/Class/DeploymentHandler/Dad.pm +++ b/lib/DBIx/Class/DeploymentHandler/Dad.pm @@ -75,7 +75,7 @@ sub upgrade { } sub downgrade { - log_info { 'upgrading' }; + log_info { 'downgrading' }; my $self = shift; my $ran_once = 0; while ( my $version_list = $self->previous_version_set ) { @@ -83,7 +83,7 @@ sub downgrade { $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] }); + $self->delete_database_version({ version => $version_list->[0] }); } log_warn { 'no version to run downgrade' } unless $ran_once; } diff --git a/t/02-instantiation-no-ddl.t b/t/02-instantiation-no-ddl.t index 1948051..289fa52 100644 --- a/t/02-instantiation-no-ddl.t +++ b/t/02-instantiation-no-ddl.t @@ -158,6 +158,10 @@ DOWN2: { baz => 'frew', }) } 'schema is at version 2'; + + is $handler->version_storage->database_version => 2, + 'database version is down to 2'; + } done_testing;