From: Arthur Axel 'fREW' Schmidt Date: Fri, 19 Mar 2010 15:22:05 +0000 (-0500) Subject: upgrade not update X-Git-Tag: v0.001000_01~90 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a41a04e5fddd753e6daf9430016df40a1cab93e2;p=dbsrgits%2FDBIx-Class-DeploymentHandler.git upgrade not update --- diff --git a/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator.pm b/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator.pm index 467581e..20435e7 100644 --- a/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator.pm +++ b/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator.pm @@ -103,13 +103,28 @@ method _ddl_schema_out_filename($type, $version, $dir) { ); } -method _ddl_schema_diff_in_filenames($type, $versions, $dir) { - $self->__ddl_in_with_prefix($type, $versions, 'diff') +method _ddl_schema_up_in_filenames($type, $versions, $dir) { + $self->__ddl_in_with_prefix($type, $versions, 'up') } -method _ddl_schema_diff_out_filename($type, $versions, $dir) { +method _ddl_schema_down_in_filenames($type, $versions, $dir) { + $self->__ddl_in_with_prefix($type, $versions, 'down') +} + +method _ddl_schema_up_out_filename($type, $versions, $dir) { + my $dirname = File::Spec->catfile( + $dir, $type, 'up', join( q(-), @{$versions} ) + ); + File::Path::mkpath($dirname) unless -d $dirname; + + return File::Spec->catfile( + $dirname, '001-auto.sql' + ); +} + +method _ddl_schema_down_out_filename($type, $versions, $dir) { my $dirname = File::Spec->catfile( - $dir, $type, 'diff', join( q(-), @{$versions} ) + $dir, $type, 'down', join( q(-), @{$versions} ) ); File::Path::mkpath($dirname) unless -d $dirname; @@ -247,7 +262,7 @@ sub prepare_install { } } -sub prepare_update { +sub prepare_upgrade { my ($self, $from_version, $to_version, $version_set) = @_; $from_version ||= $self->db_version; @@ -293,9 +308,9 @@ sub prepare_update { next; } - my $diff_file = $self->_ddl_schema_diff_out_filename($db, $version_set, $dir ); + my $diff_file = $self->_ddl_schema_up_out_filename($db, $version_set, $dir ); if(-e $diff_file) { - carp("Overwriting existing diff file - $diff_file"); + carp("Overwriting existing up-diff file - $diff_file"); unlink $diff_file; } @@ -379,7 +394,7 @@ method _read_sql_file($file) { sub _upgrade_single_step { my $self = shift; my @version_set = @{ shift @_ }; - my @upgrade_files = @{$self->_ddl_schema_diff_in_filenames( + my @upgrade_files = @{$self->_ddl_schema_up_in_filenames( $self->storage->sqlt_type, \@version_set, )}; diff --git a/lib/DBIx/Class/DeploymentHandler/HandlesDeploy.pm b/lib/DBIx/Class/DeploymentHandler/HandlesDeploy.pm index e899495..ee04448 100644 --- a/lib/DBIx/Class/DeploymentHandler/HandlesDeploy.pm +++ b/lib/DBIx/Class/DeploymentHandler/HandlesDeploy.pm @@ -2,7 +2,7 @@ package DBIx::Class::DeploymentHandler::HandlesDeploy; use Moose::Role; requires 'prepare_install'; -requires 'prepare_update'; +requires 'prepare_upgrade'; requires '_upgrade_single_step'; requires '_deploy'; diff --git a/t/02-instantiation.t b/t/02-instantiation.t index a401ec1..ebc10e5 100644 --- a/t/02-instantiation.t +++ b/t/02-instantiation.t @@ -58,7 +58,7 @@ VERSION2: { $version = $s->schema_version(); $handler->prepare_install(); - $handler->prepare_update('1.0', $version); + $handler->prepare_upgrade('1.0', $version); #ok(-e 't/sql/DBICVersion-Schema-schema-2.0-SQLite.sql', 'DDL for 2.0 got created successfully'); #ok(-e 't/sql/DBICVersion-Schema-diff-1.0-2.0-SQLite.sql', 'DDL for migration from 1.0 to 2.0 got created successfully'); dies_ok { @@ -97,8 +97,8 @@ VERSION3: { $version = $s->schema_version(); $handler->prepare_install; - $handler->prepare_update( '1.0', $version ); - $handler->prepare_update( '2.0', $version ); + $handler->prepare_upgrade( '1.0', $version ); + $handler->prepare_upgrade( '2.0', $version ); #ok(-e 't/sql/DBICVersion-Schema-schema-3.0-SQLite.sql', 'DDL for 3.0 got created successfully'); #ok(-e 't/sql/DBICVersion-Schema-diff-1.0-3.0-SQLite.sql', 'DDL for migration from 1.0 to 3.0 got created successfully'); #ok(-e 't/sql/DBICVersion-Schema-diff-2.0-3.0-SQLite.sql', 'DDL for migration from 2.0 to 3.0 got created successfully');