From: Arthur Axel 'fREW' Schmidt Date: Sat, 3 Mar 2012 19:31:02 +0000 (-0600) Subject: Allow user to specify version of schema to install X-Git-Tag: v0.002100~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=da2816e26423ff8d3dff8b3414ce5138bb202b37;p=dbsrgits%2FDBIx-Class-DeploymentHandler.git Allow user to specify version of schema to install --- diff --git a/Changes b/Changes index 9608cb7..1d1920a 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,7 @@ Revision history for {{$dist->name}} {{$NEXT}} + - Allow user to specify version of schema to install - Added better sandboxing (stolen straight from Plack::Util) for coderefs to avoid accidental leakage - Sandboxing also makes $0 and thus FindBin et al work in perl scripts diff --git a/lib/DBIx/Class/DeploymentHandler/Dad.pm b/lib/DBIx/Class/DeploymentHandler/Dad.pm index af14267..569a9f7 100644 --- a/lib/DBIx/Class/DeploymentHandler/Dad.pm +++ b/lib/DBIx/Class/DeploymentHandler/Dad.pm @@ -42,11 +42,13 @@ sub _build_schema_version { $_[0]->schema->schema_version } sub install { my $self = shift; - log_info { 'installing version ' . $self->to_version }; + + my $version = (shift @_ || {})->{version} || $self->to_version; + log_info { "installing version $version" }; croak 'Install not possible as versions table already exists in database' if $self->version_storage_is_installed; - my $ddl = $self->deploy({version=>$self->to_version}); + my $ddl = $self->deploy({ version=> $version }); $self->add_database_version({ version => $self->to_version, @@ -126,8 +128,12 @@ The version (defaults to schema's version) to migrate the database to $dh->install -Deploys the current schema into the database. Populates C with -C and C. +or + + $dh->install({ version => 1 }) + +Deploys the requested version into the database Version defaults to +L. Populates C with C and C. B: you typically need to call C<< $dh->prepare_deploy >> before you call this method. diff --git a/t/02-instantiation-wo-component.t b/t/02-instantiation-wo-component.t index fbf5723..b5fee69 100644 --- a/t/02-instantiation-wo-component.t +++ b/t/02-instantiation-wo-component.t @@ -40,7 +40,7 @@ VERSION1: { bar => 'frew', }) } 'schema not deployed'; - $handler->install; + $handler->install({ version => 1 }); dies_ok { $handler->install; } 'cannot install twice'; diff --git a/t/03-deprecated.t b/t/03-deprecated.t index f29244a..49e1ef5 100644 --- a/t/03-deprecated.t +++ b/t/03-deprecated.t @@ -39,7 +39,7 @@ VERSION1: { bar => 'frew', }) } 'schema not deployed'; - $handler->install; + $handler->install({ version => '1.0' }); dies_ok { $handler->install; } 'cannot install twice';