make DeployHandler use VersionStorage
Arthur Axel 'fREW' Schmidt [Wed, 17 Mar 2010 05:49:05 +0000 (00:49 -0500)]
lib/DBIx/Class/DeploymentHandler.pm

index 6de3e7d..76d48e0 100644 (file)
@@ -6,8 +6,9 @@ require DBIx::Class::Schema;    # loaded for type constraint
 require DBIx::Class::ResultSet; # loaded for type constraint
 use Carp::Clan '^DBIx::Class::DeploymentHandler';
 
-with 'DBIx::Class::DeploymentHandler::WithSqltDeployMethod';
-with 'DBIx::Class::DeploymentHandler::WithDatabaseToSchemaVersions';
+with 'DBIx::Class::DeploymentHandler::WithSqltDeployMethod',
+     'DBIx::Class::DeploymentHandler::WithDatabaseToSchemaVersions',
+     'DBIx::Class::DeploymentHandler::WithStandardVersionStorage';
 
 BEGIN {
   use Moose::Util::TypeConstraints;
@@ -39,14 +40,6 @@ has backup_directory => ( # configuration
   predicate  => 'has_backup_directory',
 );
 
-has version_rs => (
-  isa        => 'DBIx::Class::ResultSet',
-  is         => 'ro',
-  lazy_build => 1, # builder comes from another role...
-                   # which is... probably not how we want it
-  handles    => [qw( is_installed )],
-);
-
 has to_version => ( # configuration
   is         => 'ro',
   lazy_build => 1, # builder comes from another role...
@@ -68,14 +61,14 @@ has sqltargs => ( # configuration
 
 method install {
   carp 'Install not possible as versions table already exists in database'
-    if $self->is_installed;
+    if $self->version_storage_is_installed;
 
   my $new_version = $self->to_version;
 
   if ($new_version) {
     $self->_deploy;
 
-    $self->version_rs->create({
+    $self->add_database_version({
       version     => $new_version,
       # ddl         => $ddl,
       # upgrade_sql => $upgrade_sql,
@@ -88,7 +81,7 @@ sub upgrade {
   while ( my $version_list = $self->next_version_set ) {
     $self->_upgrade_single_step($version_list);
 
-    $self->version_rs->create({
+    $self->add_database_version({
       version     => $version_list->[-1],
       # ddl         => $ddl,
       # upgrade_sql => $upgrade_sql,