From: Arthur Axel 'fREW' Schmidt Date: Fri, 4 Jun 2010 00:57:58 +0000 (-0500) Subject: switch preinstall to initialize X-Git-Tag: v0.001000_14~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ff40cb1f9761e5118c2042e7b6f7e8bb947bd20a;p=dbsrgits%2FDBIx-Class-DeploymentHandler.git switch preinstall to initialize --- diff --git a/Changes b/Changes index fa51e72..eec354a 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,7 @@ Revision history for {{$dist->name}} {{$NEXT}} + - Rename preinstall to initialize 0.001000_13 2010-06-01 23:30:15 CST6CDT - No more serialized SQL, we serialize the SQLT schema instead diff --git a/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator.pm b/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator.pm index 2cd469e..c065916 100644 --- a/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator.pm +++ b/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator.pm @@ -127,8 +127,8 @@ method __ddl_consume_with_prefix($type, $versions, $prefix) { return [@files{sort keys %files}] } -method _ddl_preinstall_consume_filenames($type, $version) { - $self->__ddl_consume_with_prefix($type, [ $version ], 'preinstall') +method _ddl_initialize_consume_filenames($type, $version) { + $self->__ddl_consume_with_prefix($type, [ $version ], 'initialize') } method _ddl_schema_consume_filenames($type, $version) { @@ -292,14 +292,14 @@ sub deploy { ), $sql); } -sub preinstall { +sub initialize { my $self = shift; my $args = shift; my $version = $args->{version} || $self->schema_version; - log_info { "preinstalling version $version" }; + log_info { "initializing version $version" }; my $storage_type = $args->{storage_type} || $self->storage->sqlt_type; - my @files = @{$self->_ddl_preinstall_consume_filenames( + my @files = @{$self->_ddl_initialize_consume_filenames( $storage_type, $version, )}; @@ -321,7 +321,7 @@ sub preinstall { carp "$filename should define an anonymous sub but it didn't!"; } } else { - croak "A file ($filename) got to preinstall_scripts that wasn't sql or perl!"; + croak "A file ($filename) got to initialize_scripts that wasn't sql or perl!"; } } } @@ -692,7 +692,7 @@ the following example: |- downgrade | `- 2-1 | `- 001-auto.sql - |- preinstall + |- initialize | `- 1 | |- 001-create_database.pl | `- 002-create_users_and_permissions.pl @@ -718,11 +718,11 @@ C<$sql_migration_dir/_common/upgrade/1-2/002-generate-customers.pl>. C<.pl> files don't have to be in the C<_common> directory, but most of the time they should be, because perl scripts are generally database independent. -Note that unlike most steps in the process, C will not run SQL, as -there may not even be an database at preinstall time. It will run perl scripts +Note that unlike most steps in the process, C will not run SQL, as +there may not even be an database at initialize time. It will run perl scripts just like the other steps in the process, but nothing is passed to them. Until people have used this more it will remain freeform, but a recommended use -of preinstall is to have it prompt for username and password, and then call the +of initialize is to have it prompt for username and password, and then call the appropriate C<< CREATE DATABASE >> commands etc. =head2 Directory Specification @@ -768,7 +768,7 @@ already have. This directory can containt the following directories itself: =over 2 -=item C Gets run before the C is Ced. Has the +=item C Gets run before the C is Ced. Has the same structure as the C subdirectory as well; that is, it has a directory for each schema version. Unlike C, C, and C though, it can only run C<.pl> files, and the coderef in the perl files get diff --git a/lib/DBIx/Class/DeploymentHandler/HandlesDeploy.pm b/lib/DBIx/Class/DeploymentHandler/HandlesDeploy.pm index 83702f1..14c3256 100644 --- a/lib/DBIx/Class/DeploymentHandler/HandlesDeploy.pm +++ b/lib/DBIx/Class/DeploymentHandler/HandlesDeploy.pm @@ -3,7 +3,7 @@ use Moose::Role; # ABSTRACT: Interface for deploy methods -requires 'preinstall'; +requires 'initialize'; requires 'prepare_deploy'; requires 'deploy'; @@ -23,9 +23,9 @@ requires 'downgrade_single_step'; __END__ -=method preinstall +=method initialize - $dh->preinstall({ + $dh->initialize({ version => 1, storage_type => 'SQLite' }); diff --git a/t/04-preconnect.t b/t/04-preconnect.t index 7f58d4c..4e3a77b 100644 --- a/t/04-preconnect.t +++ b/t/04-preconnect.t @@ -33,8 +33,8 @@ VERSION1: { ok !$s->storage->connected, 'creating handler did not connect'; ok($handler, 'DBIx::Class::DeploymentHandler w/1 instantiates correctly'); - mkpath('t/sql/SQLite/preinstall/1'); - $handler->preinstall({ version => 1, storage_type => 'SQLite' }); + mkpath('t/sql/SQLite/initialize/1'); + $handler->initialize({ version => 1, storage_type => 'SQLite' }); ok !$s->storage->connected, 'creating schema did not connect'; } done_testing; diff --git a/t/deploy_methods/sql_translator.t b/t/deploy_methods/sql_translator.t index 4c5a097..49b2c16 100644 --- a/t/deploy_methods/sql_translator.t +++ b/t/deploy_methods/sql_translator.t @@ -29,12 +29,12 @@ VERSION1: { $dm->prepare_deploy; - mkpath(catfile(qw( t sql SQLite preinstall 1.0 ))); + mkpath(catfile(qw( t sql SQLite initialize 1.0 ))); open my $prerun, '>', - catfile(qw( t sql SQLite preinstall 1.0 003-semiautomatic.pl )); + catfile(qw( t sql SQLite initialize 1.0 003-semiautomatic.pl )); print {$prerun} "sub {use File::Touch; touch(q(foobar));}"; close $prerun; - $dm->preinstall({ version => '1.0' }); + $dm->initialize({ version => '1.0' }); ok -e 'foobar';