X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits%2FDBIx-Class-DeploymentHandler.git;a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FDeploymentHandler%2FDeployMethod%2FSQL%2FTranslator.pm;h=658b143524ab2a6529536cf0debc019d6ebc162a;hp=9efa8d427e64a9d248cf6bc6170b85d37751637a;hb=cd41f44ff6cfcfb299381521f8e1ec2afc7b8991;hpb=dc223c8897fd237cffda64a85d5e15be01f8bcbd diff --git a/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator.pm b/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator.pm index 9efa8d4..658b143 100644 --- a/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator.pm +++ b/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator.pm @@ -264,19 +264,20 @@ sub _split_sql_chunk { s/^(?:BEGIN|BEGIN TRANSACTION|COMMIT).*//mgi; # trim whitespaces - s/^\s+|\s+$//mg; + s/^\s+//gm; + s/\s+$//gm; # remove comments s/^--.*//gm; # remove blank lines - s/^\n//mg; + s/^\n//gm; # put on single line s/\n/ /g; } - return @sql; + return grep $_, @sql; } sub _run_sql { @@ -359,8 +360,9 @@ sub deploy { log_info { "deploying version $version" }; my $sqlt_type = $self->storage->sqlt_type; my $sql; + my $sqltargs = $self->sql_translator_args; if ($self->ignore_ddl) { - $sql = $self->_sql_from_yaml({}, + $sql = $self->_sql_from_yaml($sqltargs, '_ddl_protoschema_deploy_consume_filenames', $sqlt_type ); } @@ -483,10 +485,10 @@ sub _sql_from_yaml { my @sql; my $actual_file = $self->$from_file($version); - for my $yaml_filename (@{ + for my $yaml_filename (@{( DlogS_trace { "generating SQL from Serialized SQL Files: $_" } (ref $actual_file?$actual_file:[$actual_file]) - }) { + )}) { my $sqlt = SQL::Translator->new({ add_drop_table => 0, parser => 'SQL::Translator::Parser::YAML', @@ -589,7 +591,13 @@ sub prepare_deploy { my $self = shift; $self->prepare_protoschema({ # Exclude __VERSION so that it gets installed separately - parser_args => { sources => [grep { $_ ne '__VERSION' } $self->schema->sources], } + parser_args => { + sources => [ + sort { $a cmp $b } + grep { $_ ne '__VERSION' } + $self->schema->sources + ], + } }, '_ddl_protoschema_produce_filename'); $self->_prepare_install({}, '_ddl_protoschema_produce_filename', '_ddl_schema_produce_filename'); }