From: Arthur Axel 'fREW' Schmidt Date: Mon, 31 May 2010 20:48:14 +0000 (-0500) Subject: Make ignore_ddl test fail X-Git-Tag: v0.001000_13~11 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=93460690e9d4a399f18345d2654d5f4c35abdb46;p=dbsrgits%2FDBIx-Class-DeploymentHandler.git Make ignore_ddl test fail --- diff --git a/lib/DBIx/Class/DeploymentHandler.pm b/lib/DBIx/Class/DeploymentHandler.pm index f9b11fe..fd1d6af 100644 --- a/lib/DBIx/Class/DeploymentHandler.pm +++ b/lib/DBIx/Class/DeploymentHandler.pm @@ -12,7 +12,7 @@ with 'DBIx::Class::DeploymentHandler::WithApplicatorDumple' => { class_name => 'DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator', delegate_name => 'deploy_method', attributes_to_assume => [qw(schema schema_version)], - attributes_to_copy => [qw( databases script_directory sql_translator_args )], + attributes_to_copy => [qw( ignore_ddl databases script_directory sql_translator_args )], }, 'DBIx::Class::DeploymentHandler::WithApplicatorDumple' => { interface_role => 'DBIx::Class::DeploymentHandler::HandlesVersioning', diff --git a/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator.pm b/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator.pm index dfc0b5e..301bdb4 100644 --- a/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator.pm +++ b/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator.pm @@ -25,6 +25,12 @@ use File::Spec::Functions; with 'DBIx::Class::DeploymentHandler::HandlesDeploy'; +has ignore_ddl => ( + isa => 'Bool', + is => 'ro', + default => undef, +); + has schema => ( isa => 'DBIx::Class::Schema', is => 'ro', @@ -228,15 +234,33 @@ method _run_sql_and_perl($filenames) { return $sql; } +method _deploy($version) { + if (!$self->ignore_ddl) { + return $self->_run_sql_and_perl($self->_ddl_schema_consume_filenames( + $self->storage->sqlt_type, + $version, + )); + } else { + my $sqlt = SQL::Translator->new({ + add_drop_table => 1, + parser => 'SQL::Translator::Parser::YAML', + producer => $self->storage->sqlt_type; + %{$sqltargs}, + }); + + my $yaml_filename = $self->$from_file($version); + + my @sql = $sqlt->translate($yaml_filename); + croak("Failed to translate to $db, skipping. (" . $sqlt->error . ")") + unless $sql; + } +} + sub deploy { my $self = shift; my $version = (shift @_ || {})->{version} || $self->schema_version; log_info { "deploying version $version" }; - - return $self->_run_sql_and_perl($self->_ddl_schema_consume_filenames( - $self->storage->sqlt_type, - $version, - )); + $self->_deploy($version); } sub preinstall { @@ -283,6 +307,8 @@ sub _prepare_install { my $dir = $self->script_directory; my $version = $self->schema_version; + return if $self->ignore_ddl; + my $sqlt = SQL::Translator->new({ add_drop_table => 1, parser => 'SQL::Translator::Parser::YAML', @@ -397,6 +423,8 @@ method _prepare_changegrade($from_version, $to_version, $version_set, $direction my $dir = $self->script_directory; my $sqltargs = $self->sql_translator_args; + return if $self->ignore_ddl; + my $schema_version = $self->schema_version; $sqltargs = {