From: Arthur Axel 'fREW' Schmidt Date: Sat, 20 Mar 2010 22:14:50 +0000 (-0500) Subject: insert ddl into database; fix tests to ingore that X-Git-Tag: v0.001000_01~66 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=566925dfdff725b5ea43a9a5600bf26044df418c;p=dbsrgits%2FDBIx-Class-DeploymentHandler.git insert ddl into database; fix tests to ingore that --- diff --git a/lib/DBIx/Class/DeploymentHandler.pm b/lib/DBIx/Class/DeploymentHandler.pm index 1690096..64c8d49 100644 --- a/lib/DBIx/Class/DeploymentHandler.pm +++ b/lib/DBIx/Class/DeploymentHandler.pm @@ -65,17 +65,12 @@ method install { carp 'Install not possible as versions table already exists in database' if $self->version_storage_is_installed; - my $new_version = $self->to_version; + my $ddl = $self->_deploy; - if ($new_version) { - $self->_deploy; - - $self->version_storage->add_database_version({ - version => $new_version, - # ddl => $ddl, - # upgrade_sql => $upgrade_sql, - }); - } + $self->version_storage->add_database_version({ + version => $self->to_version, + ddl => $ddl, + }); } sub upgrade { diff --git a/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator.pm b/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator.pm index 2cea383..5ec655e 100644 --- a/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator.pm +++ b/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator.pm @@ -148,12 +148,12 @@ sub _deploy { my $guard = $self->schema->txn_scope_guard if $self->txn_wrap; - foreach my $line ( - map @{$self->_read_sql_file($_)}, @{$self->_ddl_schema_consume_filenames( + my @sql = map @{$self->_read_sql_file($_)}, @{$self->_ddl_schema_consume_filenames( $self->storage->sqlt_type, $self->schema_version - )} - ) { + )}; + + foreach my $line (@sql) { $storage->_query_start($line); try { # do a dbh_do cycle here, as we need some error checking in @@ -167,6 +167,7 @@ sub _deploy { } $guard->commit if $self->txn_wrap; + return join "\n", @sql; } sub prepare_install { diff --git a/t/version_storages/standard.t b/t/version_storages/standard.t index aa357ce..dcd4c2f 100644 --- a/t/version_storages/standard.t +++ b/t/version_storages/standard.t @@ -45,17 +45,11 @@ $handler->install(); ok( $vs->version_storage_is_installed, 'VersionStorage is now installed' ); -cmp_deeply( - [ map +{ - version => $_->version, - ddl => $_->ddl, - upgrade_sql => $_->upgrade_sql, - }, $vs->version_rs->search(undef, {order_by => 'id'})->all], - [{ - version => '1.0', - ddl => undef, - upgrade_sql => undef - }], +ok( + eq_array( + [ $vs->version_rs->search(undef, {order_by => 'id'})->get_column('version')->all], + [ '1.0' ], + ), 'initial version works correctly' ); @@ -65,21 +59,11 @@ $vs->add_database_version({ }); is( $vs->database_version, '2.0', 'database version is 2.0'); -cmp_deeply( - [ map +{ - version => $_->version, - ddl => $_->ddl, - upgrade_sql => $_->upgrade_sql, - }, $vs->version_rs->search(undef, {order_by => 'id'})->all], - [{ - version => '1.0', - ddl => undef, - upgrade_sql => undef - },{ - version => '2.0', - ddl => undef, - upgrade_sql => undef - }], +ok( + eq_array( + [ $vs->version_rs->search(undef, {order_by => 'id'})->get_column('version')->all], + [ '1.0', '2.0', ], + ), 'adding another version works correctly' );