X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FDeploymentHandler%2FHandlesDeploy.pm;h=c931d42665781a75722357b7e4cb71854e3f0d1b;hb=1fcd4fe6717e0809422856c89673fc78b43174bb;hp=34e83adf74c1e149cbbcd1f78edc2a0cab73c6fe;hpb=ed1721b92e5774426f63bbf69bc4b2c997fbf62e;p=dbsrgits%2FDBIx-Class-DeploymentHandler.git diff --git a/lib/DBIx/Class/DeploymentHandler/HandlesDeploy.pm b/lib/DBIx/Class/DeploymentHandler/HandlesDeploy.pm index 34e83ad..c931d42 100644 --- a/lib/DBIx/Class/DeploymentHandler/HandlesDeploy.pm +++ b/lib/DBIx/Class/DeploymentHandler/HandlesDeploy.pm @@ -1,67 +1,120 @@ package DBIx::Class::DeploymentHandler::HandlesDeploy; use Moose::Role; -requires 'prepare_install'; +# ABSTRACT: Interface for deploy methods + +requires 'initialize'; + +requires 'prepare_deploy'; +requires 'deploy'; + requires 'prepare_resultsource_install'; requires 'install_resultsource'; + requires 'prepare_upgrade'; -requires 'prepare_downgrade'; requires 'upgrade_single_step'; + +requires 'prepare_downgrade'; requires 'downgrade_single_step'; -requires 'deploy'; + +requires 'txn_do'; 1; -# should this be renamed prepare_deploy? +# vim: ts=2 sw=2 expandtab + +__END__ -=method prepare_install +=method initialize - $deploy_method->prepare_install; + $dh->initialize({ + version => 1, + storage_type => 'SQLite' + }); + +Run scripts before deploying to the database + +=method prepare_deploy + + $dh->prepare_deploy + +Generate the needed data files to install the schema to the database. =method deploy - $dh->deploy + $dh->deploy({ version => 1 }) Deploy the schema to the database. =method prepare_resultsource_install - $deploy_method->prepare_resultsource_install($resultset->result_source); + $dh->prepare_resultsource_install({ + result_source => $resultset->result_source, + }) + +Takes a L and generates a single migration file to +create the resultsource's table. =method install_resultsource - $deploy_method->prepare_resultsource_install($resultset->result_source); + $dh->install_resultsource({ + result_source => $resultset->result_source, + version => 1, + }) -# for updates prepared automatically (rob's stuff) -# one would want to explicitly set $version_set to -# [$to_version] +Takes a L and runs a single migration file to +deploy the resultsource's table. =method prepare_upgrade - $deploy_method->prepare_upgrade(1, 2, [1, 2]); + $dh->prepare_upgrade({ + from_version => 1, + to_version => 2, + version_set => [1, 2] + }); -# for updates prepared automatically (rob's stuff) -# one would want to explicitly set $version_set to -# [$to_version] +Takes two versions and a version set. This basically is supposed to generate +the needed C to migrate up from the first version to the second version. +The version set uniquely identifies the migration. =method prepare_downgrade - $deploy_method->prepare_downgrade(2, 1, [1, 2]); + $dh->prepare_downgrade({ + from_version => 1, + to_version => 2, + version_set => [1, 2] + }); + +Takes two versions and a version set. This basically is supposed to generate +the needed C to migrate down from the first version to the second version. +The version set uniquely identifies the migration and should match its +respective upgrade version set. =method upgrade_single_step - my ($ddl, $sql) = @{$dh->upgrade_single_step($version_set)||[]} + my ($ddl, $sql) = @{ + $dh->upgrade_single_step({ version_set => $version_set }) + ||[]} -call a single upgrade migration. Takes an arrayref describing the version to -upgrade to. Optionally return an arrayref containing C<$ddl> describing -version installed and C<$sql> used to get to that version. +Call a single upgrade migration. Takes a version set as an argument. +Optionally return C<< [ $ddl, $upgrade_sql ] >> where C<$ddl> is the DDL for +that version of the schema and C<$upgrade_sql> is the SQL that was run to +upgrade the database. =method downgrade_single_step $dh->downgrade_single_step($version_set); -call a single downgrade migration. Takes an arrayref describing the version to -downgrade to. +Call a single downgrade migration. Takes a version set as an argument. +Optionally return C<< [ $ddl, $upgrade_sql ] >> where C<$ddl> is the DDL for +that version of the schema and C<$upgrade_sql> is the SQL that was run to +upgrade the database. + +=method txn_do + + $dh->txn_do(sub { ... }) + +Wrap the passed coderef in a transaction (if transactions are enabled.) =head1 KNOWN IMPLEMENTATIONS @@ -77,6 +130,3 @@ L =back -__END__ - -vim: ts=2 sw=2 expandtab