From: Arthur Axel 'fREW' Schmidt Date: Tue, 18 May 2010 04:43:32 +0000 (-0500) Subject: rename upgrade_directory attr to script_directory X-Git-Tag: v0.001000_10~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=91adde755e5808a1ec12bcf00e683e3754964cc9;p=dbsrgits%2FDBIx-Class-DeploymentHandler.git rename upgrade_directory attr to script_directory --- diff --git a/Changes b/Changes index e87649d..d1bbc0f 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,7 @@ Revision history for {{$dist->name}} {{$NEXT}} + - upgrade_directory is wrong and vague, instead we use script_directory - stricter validation (no undef) on versions to prevent weird surprises - change method args to named args - document method args diff --git a/lib/DBIx/Class/DeploymentHandler.pm b/lib/DBIx/Class/DeploymentHandler.pm index 4c9c83d..ae54483 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 => ['schema'], - attributes_to_copy => [qw( databases upgrade_directory sql_translator_args )], + attributes_to_copy => [qw( databases script_directory sql_translator_args )], }, 'DBIx::Class::DeploymentHandler::WithApplicatorDumple' => { interface_role => 'DBIx::Class::DeploymentHandler::HandlesVersioning', diff --git a/lib/DBIx/Class/DeploymentHandler/Cookbook/CustomResultSource.pod b/lib/DBIx/Class/DeploymentHandler/Cookbook/CustomResultSource.pod index fed4a9f..a1ad2a6 100644 --- a/lib/DBIx/Class/DeploymentHandler/Cookbook/CustomResultSource.pod +++ b/lib/DBIx/Class/DeploymentHandler/Cookbook/CustomResultSource.pod @@ -51,7 +51,7 @@ table being set on the original result. class_name => 'DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator', delegate_name => 'deploy_method', attributes_to_assume => ['schema'], - attributes_to_copy => [qw( databases upgrade_directory sql_translator_args )], + attributes_to_copy => [qw( 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 b1a2c01..c45dafd 100644 --- a/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator.pm +++ b/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator.pm @@ -43,7 +43,7 @@ has sql_translator_args => ( is => 'ro', default => sub { {} }, ); -has upgrade_directory => ( +has script_directory => ( isa => 'Str', is => 'ro', required => 1, @@ -72,7 +72,7 @@ has schema_version => ( method _build_schema_version { $self->schema->schema_version } method __ddl_consume_with_prefix($type, $versions, $prefix) { - my $base_dir = $self->upgrade_directory; + my $base_dir = $self->script_directory; my $main = catfile( $base_dir, $type ); my $generic = catfile( $base_dir, '_generic' ); @@ -114,7 +114,7 @@ method _ddl_schema_consume_filenames($type, $version) { } method _ddl_schema_produce_filename($type, $version) { - my $dirname = catfile( $self->upgrade_directory, $type, 'schema', $version ); + my $dirname = catfile( $self->script_directory, $type, 'schema', $version ); mkpath($dirname) unless -d $dirname; return catfile( $dirname, '001-auto.sql' ); @@ -129,7 +129,7 @@ method _ddl_schema_down_consume_filenames($type, $versions) { } method _ddl_schema_up_produce_filename($type, $versions) { - my $dir = $self->upgrade_directory; + my $dir = $self->script_directory; my $dirname = catfile( $dir, $type, 'up', join q(-), @{$versions}); mkpath($dirname) unless -d $dirname; @@ -243,7 +243,7 @@ sub _prepare_install { my $to_file = shift; my $schema = $self->schema; my $databases = $self->databases; - my $dir = $self->upgrade_directory; + my $dir = $self->script_directory; my $version = $self->schema_version; my $sqlt = SQL::Translator->new({ @@ -283,7 +283,7 @@ sub _resultsource_install_filename { my ($self, $source_name) = @_; return sub { my ($self, $type, $version) = @_; - my $dirname = catfile( $self->upgrade_directory, $type, 'schema', $version ); + my $dirname = catfile( $self->script_directory, $type, 'schema', $version ); mkpath($dirname) unless -d $dirname; return catfile( $dirname, "001-auto-$source_name.sql" ); @@ -338,7 +338,7 @@ sub prepare_downgrade { method _prepare_changegrade($from_version, $to_version, $version_set, $direction) { my $schema = $self->schema; my $databases = $self->databases; - my $dir = $self->upgrade_directory; + my $dir = $self->script_directory; my $sqltargs = $self->sql_translator_args; my $schema_version = $self->schema_version; @@ -603,9 +603,9 @@ and generate the DDL. This is automatically created with L. The arguments that get passed to L when it's used. -=attr upgrade_directory +=attr script_directory -The directory (default C<'sql'>) that upgrades are stored in +The directory (default C<'sql'>) that scripts are stored in =attr databases diff --git a/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator/Deprecated.pm b/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator/Deprecated.pm index db0a1a4..813013c 100644 --- a/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator/Deprecated.pm +++ b/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator/Deprecated.pm @@ -18,7 +18,7 @@ method _ddl_schema_produce_filename($type, $version) { $filename =~ s/::/-/g; $filename = catfile( - $self->upgrade_directory, "$filename-$version-$type.sql" + $self->script_directory, "$filename-$version-$type.sql" ); return $filename; @@ -29,7 +29,7 @@ method _ddl_schema_up_produce_filename($type, $versions, $dir) { $filename =~ s/::/-/g; $filename = catfile( - $self->upgrade_directory, "$filename-" . join( q(-), @{$versions} ) . "-$type.sql" + $self->script_directory, "$filename-" . join( q(-), @{$versions} ) . "-$type.sql" ); return $filename; diff --git a/lib/DBIx/Class/DeploymentHandler/Deprecated.pm b/lib/DBIx/Class/DeploymentHandler/Deprecated.pm index ebac393..d460fb4 100644 --- a/lib/DBIx/Class/DeploymentHandler/Deprecated.pm +++ b/lib/DBIx/Class/DeploymentHandler/Deprecated.pm @@ -13,7 +13,7 @@ with 'DBIx::Class::DeploymentHandler::WithApplicatorDumple' => { class_name => 'DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator::Deprecated', delegate_name => 'deploy_method', attributes_to_assume => ['schema'], - attributes_to_copy => [qw( upgrade_directory databases sql_translator_args )], + attributes_to_copy => [qw( script_directory databases sql_translator_args )], }, 'DBIx::Class::DeploymentHandler::WithApplicatorDumple' => { interface_role => 'DBIx::Class::DeploymentHandler::HandlesVersionStorage', diff --git a/t/02-instantiation-wo-component.t b/t/02-instantiation-wo-component.t index 063f3a7..e607828 100644 --- a/t/02-instantiation-wo-component.t +++ b/t/02-instantiation-wo-component.t @@ -24,7 +24,7 @@ VERSION1: { $DBICVersion::Schema::VERSION = 1; ok($s, 'DBICVersion::Schema 1 instantiates correctly'); my $handler = DH->new({ - upgrade_directory => $sql_dir, + script_directory => $sql_dir, schema => $s, databases => 'SQLite', sql_translator_args => { add_drop_table => 0 }, @@ -57,7 +57,7 @@ VERSION2: { $DBICVersion::Schema::VERSION = 2; ok($s, 'DBICVersion::Schema 2 instantiates correctly'); my $handler = DH->new({ - upgrade_directory => $sql_dir, + script_directory => $sql_dir, schema => $s, databases => 'SQLite', }); @@ -94,7 +94,7 @@ VERSION3: { $DBICVersion::Schema::VERSION = 3; ok($s, 'DBICVersion::Schema 3 instantiates correctly'); my $handler = DH->new({ - upgrade_directory => $sql_dir, + script_directory => $sql_dir, schema => $s, databases => 'SQLite', }); @@ -127,7 +127,7 @@ DOWN2: { $DBICVersion::Schema::VERSION = 2; ok($s, 'DBICVersion::Schema 2 instantiates correctly'); my $handler = DH->new({ - upgrade_directory => $sql_dir, + script_directory => $sql_dir, schema => $s, databases => 'SQLite', }); diff --git a/t/02-instantiation.t b/t/02-instantiation.t index 8a0de18..36e8e4f 100644 --- a/t/02-instantiation.t +++ b/t/02-instantiation.t @@ -24,7 +24,7 @@ VERSION1: { $DBICVersion::Schema::VERSION = 1; ok($s, 'DBICVersion::Schema 1 instantiates correctly'); my $handler = DH->new({ - upgrade_directory => $sql_dir, + script_directory => $sql_dir, schema => $s, databases => 'SQLite', sql_translator_args => { add_drop_table => 0 }, @@ -57,7 +57,7 @@ VERSION2: { $DBICVersion::Schema::VERSION = 2; ok($s, 'DBICVersion::Schema 2 instantiates correctly'); my $handler = DH->new({ - upgrade_directory => $sql_dir, + script_directory => $sql_dir, schema => $s, databases => 'SQLite', }); @@ -94,7 +94,7 @@ VERSION3: { $DBICVersion::Schema::VERSION = 3; ok($s, 'DBICVersion::Schema 3 instantiates correctly'); my $handler = DH->new({ - upgrade_directory => $sql_dir, + script_directory => $sql_dir, schema => $s, databases => 'SQLite', }); @@ -127,7 +127,7 @@ DOWN2: { $DBICVersion::Schema::VERSION = 2; ok($s, 'DBICVersion::Schema 2 instantiates correctly'); my $handler = DH->new({ - upgrade_directory => $sql_dir, + script_directory => $sql_dir, schema => $s, databases => 'SQLite', }); diff --git a/t/03-deprecated.t b/t/03-deprecated.t index 9b83045..84e25f2 100644 --- a/t/03-deprecated.t +++ b/t/03-deprecated.t @@ -23,7 +23,7 @@ VERSION1: { is $s->schema_version, '1.0', 'schema version is at 1.0'; ok($s, 'DBICVersion::Schema 1.0 instantiates correctly'); my $handler = Deprecated->new({ - upgrade_directory => $sql_dir, + script_directory => $sql_dir, schema => $s, databases => 'SQLite', sql_translator_args => { add_drop_table => 0 }, @@ -56,7 +56,7 @@ VERSION2: { is $s->schema_version, '2.0', 'schema version is at 2.0'; ok($s, 'DBICVersion::Schema 2.0 instantiates correctly'); my $handler = Deprecated->new({ - upgrade_directory => $sql_dir, + script_directory => $sql_dir, schema => $s, databases => 'SQLite', }); @@ -93,7 +93,7 @@ VERSION3: { is $s->schema_version, '3.0', 'schema version is at 3.0'; ok($s, 'DBICVersion::Schema 3.0 instantiates correctly'); my $handler = Deprecated->new({ - upgrade_directory => $sql_dir, + script_directory => $sql_dir, schema => $s, databases => 'SQLite', }); diff --git a/t/04-preconnect.t b/t/04-preconnect.t index 6260194..7f58d4c 100644 --- a/t/04-preconnect.t +++ b/t/04-preconnect.t @@ -25,7 +25,7 @@ VERSION1: { ok($s, 'DBICVersion::Schema 1 instantiates correctly'); ok !$s->storage->connected, 'creating schema did not connect'; my $handler = DH->new({ - upgrade_directory => $sql_dir, + script_directory => $sql_dir, schema => $s, databases => 'SQLite', sql_translator_args => { add_drop_table => 0 }, diff --git a/t/deploy_methods/sql_translator.t b/t/deploy_methods/sql_translator.t index 704b998..f7a7cf2 100644 --- a/t/deploy_methods/sql_translator.t +++ b/t/deploy_methods/sql_translator.t @@ -20,7 +20,7 @@ VERSION1: { my $s = DBICVersion::Schema->connect(@connection); my $dm = Translator->new({ schema => $s, - upgrade_directory => $sql_dir, + script_directory => $sql_dir, databases => ['SQLite'], sql_translator_args => { add_drop_table => 0 }, }); @@ -85,7 +85,7 @@ VERSION2: { my $s = DBICVersion::Schema->connect(@connection); my $dm = Translator->new({ schema => $s, - upgrade_directory => $sql_dir, + script_directory => $sql_dir, databases => ['SQLite'], sql_translator_args => { add_drop_table => 0 }, txn_wrap => 1, @@ -192,7 +192,7 @@ VERSION3: { my $s = DBICVersion::Schema->connect(@connection); my $dm = Translator->new({ schema => $s, - upgrade_directory => $sql_dir, + script_directory => $sql_dir, databases => ['SQLite'], sql_translator_args => { add_drop_table => 0 }, txn_wrap => 0, diff --git a/t/deploy_methods/sql_translator_deprecated.t b/t/deploy_methods/sql_translator_deprecated.t index 4038abe..5a93821 100644 --- a/t/deploy_methods/sql_translator_deprecated.t +++ b/t/deploy_methods/sql_translator_deprecated.t @@ -21,7 +21,7 @@ VERSION1: { my $s = DBICVersion::Schema->connect(@connection); my $dm = Deprecated->new({ schema => $s, - upgrade_directory => $sql_dir, + script_directory => $sql_dir, databases => ['SQLite'], sql_translator_args => { add_drop_table => 0 }, }); @@ -53,7 +53,7 @@ VERSION2: { my $s = DBICVersion::Schema->connect(@connection); my $dm = Deprecated->new({ schema => $s, - upgrade_directory => $sql_dir, + script_directory => $sql_dir, databases => ['SQLite'], }); diff --git a/t/version_storages/standard.t b/t/version_storages/standard.t index 5a36e1a..211fde6 100644 --- a/t/version_storages/standard.t +++ b/t/version_storages/standard.t @@ -27,7 +27,7 @@ DBICDHTest::ready; my $dm = Translator->new({ schema => $s, - upgrade_directory => $sql_dir, + script_directory => $sql_dir, databases => ['SQLite'], sql_translator_args => { add_drop_table => 0 }, });