migrate unneeded code out of main class and into delegate class
[dbsrgits/DBIx-Class-DeploymentHandler.git] / lib / DBIx / Class / DeploymentHandler.pm
index b1c96de..c06f124 100644 (file)
@@ -3,12 +3,8 @@ package DBIx::Class::DeploymentHandler;
 use Moose;
 use Method::Signatures::Simple;
 require DBIx::Class::Schema;    # loaded for type constraint
-require DBIx::Class::Storage;   # loaded for type constraint
 require DBIx::Class::ResultSet; # loaded for type constraint
 use Carp::Clan '^DBIx::Class::DeploymentHandler';
-use SQL::Translator;
-require SQL::Translator::Diff;
-use Try::Tiny;
 
 with 'DBIx::Class::DeploymentHandler::WithSqltDeployMethod';
 
@@ -43,18 +39,6 @@ has backup_directory => ( # configuration
   predicate  => 'has_backup_directory',
 );
 
-has storage => (
-  isa        => 'DBIx::Class::Storage',
-  is         => 'ro',
-  lazy_build => 1,
-);
-
-method _build_storage {
-  my $s = $self->schema->storage;
-  $s->_determine_driver;
-  $s
-}
-
 has do_backup => ( # configuration
   isa     => 'Bool',
   is      => 'ro',
@@ -86,36 +70,6 @@ has sqltargs => ( # configuration
   default => sub { {} },
 );
 
-method deploy {
-  my $storage  = $self->storage;
-
-  my $deploy = sub {
-    my $line = shift;
-    return if(!$line || $line =~ /^--|^BEGIN TRANSACTION|^COMMIT|^\s+$/);
-    $storage->_query_start($line);
-    try {
-      # do a dbh_do cycle here, as we need some error checking in
-      # place (even though we will ignore errors)
-      $storage->dbh_do (sub { $_[1]->do($line) });
-    }
-    catch {
-      carp "$_ (running '${line}')"
-    }
-    $storage->_query_end($line);
-  };
-  my @statements = $self->deployment_statements;
-  if (@statements > 1) {
-    foreach my $statement (@statements) {
-      $deploy->( $statement );
-    }
-  }
-  elsif (@statements == 1) {
-    foreach my $line ( split(";\n", $statements[0])) {
-      $deploy->( $line );
-    }
-  }
-}
-
 method install($new_version) {
   carp 'Install not possible as versions table already exists in database'
     if $self->is_installed;
@@ -180,4 +134,4 @@ __PACKAGE__->meta->make_immutable;
 
 __END__
 
-vim: ts=2,sw=2,expandtab
+vim: ts=2 sw=2 expandtab