From: Arthur Axel 'fREW' Schmidt Date: Fri, 19 Mar 2010 00:06:31 +0000 (-0500) Subject: autocreate dirs X-Git-Tag: v0.001000_01~94 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=85998cd9d9a2df057c1d70c692994215473adda7;p=dbsrgits%2FDBIx-Class-DeploymentHandler.git autocreate dirs --- diff --git a/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator.pm b/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator.pm index 7622ff2..8b225bf 100644 --- a/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator.pm +++ b/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator.pm @@ -6,6 +6,7 @@ use SQL::Translator; require SQL::Translator::Diff; require DBIx::Class::Storage; # loaded for type constraint use autodie; +use File::Path; with 'DBIx::Class::DeploymentHandler::HandlesDeploy'; @@ -55,49 +56,26 @@ has _filedata => ( ); method _ddl_schema_in_filenames($type, $version, $dir) { - my $filename = ref $self->schema; - $filename =~ s/::/-/g; - - my %files; - - if (-d "$dir/$type") { - my $dirname = File::Spec->catfile( - $dir, $type, 'schema', $version, '001-auto.sql' - ); - opendir my $dh, $dirname; - %files = map { $_ => "$dirname/$_" } grep { -f "$dirname/$_" } readdir($dh); - closedir $dh; - - } elsif (-d "$dir/_generic") { - $filename = File::Spec->catfile( - $dir, '_generic', 'schema', $version, '001-auto.sql' - ); - } else { - $filename = File::Spec->catfile( - $dir, '_common', 'schema', $version, '001-auto.sql' - ); - } + my $filename = File::Spec->catfile( + $dir, $type, 'schema', $version, '001-auto.sql' + ); - return [$filename]; + return [ $filename ]; } method _ddl_schema_out_filename($type, $version, $dir) { - my $filename = ref $self->schema; - $filename =~ s/::/-/g; - - $filename = File::Spec->catfile( - $dir, $type, 'schema', $version, '001-auto.sql' - ); + my $dirname = File::Spec->catfile( + $dir, $type, 'schema', $version ); + File::Path::mkpath($dirname) unless -d $dirname; - return $filename; + return File::Spec->catfile( + $dirname, '001-auto.sql' + ); } method _ddl_schema_diff_in_filenames($type, $versions, $dir) { - my $filename = ref $self->schema; - $filename =~ s/::/-/g; - - $filename = File::Spec->catfile( + my $filename = File::Spec->catfile( $dir, $type, 'diff', join( q(-), @{$versions} ), '001-auto.sql' ); @@ -105,14 +83,14 @@ method _ddl_schema_diff_in_filenames($type, $versions, $dir) { } method _ddl_schema_diff_out_filename($type, $versions, $dir) { - my $filename = ref $self->schema; - $filename =~ s/::/-/g; - - $filename = File::Spec->catfile( - $dir, $type, 'diff', join( q(-), @{$versions} ), '001-auto.sql' + my $dirname = File::Spec->catfile( + $dir, $type, 'diff', join( q(-), @{$versions} ) ); + File::Path::mkpath($dirname) unless -d $dirname; - return $filename; + return File::Spec->catfile( + $dirname, '001-auto.sql' + ); } method _deployment_statements {