DeployMethod should not know anything about versioning
[dbsrgits/DBIx-Class-DeploymentHandler.git] / lib / DBIx / Class / DeploymentHandler / DeployMethod / SQL / Translator.pm
index c4e62f5..0f55471 100644 (file)
@@ -6,6 +6,7 @@ use SQL::Translator;
 require SQL::Translator::Diff;
 require DBIx::Class::Storage;   # loaded for type constraint
 
+with 'DBIx::Class::DeploymentHandler::HandlesDeploy';
 use Carp 'carp';
 
 has storage => (
@@ -20,17 +21,6 @@ method _build_storage {
   $s
 }
 
-has backup_directory => (
-  isa => 'Str',
-  is  => 'ro',
-);
-
-has do_backup => (
-  isa     => 'Bool',
-  is      => 'ro',
-  default => undef,
-);
-
 has sqltargs => (
   isa => 'HashRef',
   is  => 'ro',
@@ -43,18 +33,6 @@ has upgrade_directory => (
   default  => 'sql',
 );
 
-has version_rs => (
-  isa        => 'DBIx::Class::ResultSet',
-  is         => 'ro',
-  lazy_build => 1,
-  handles    => [qw( is_installed db_version )],
-);
-
-method _build_version_rs {
-   $self->schema->set_us_up_the_bomb;
-   $self->schema->resultset('__VERSION')
-}
-
 has databases => (
   coerce  => 1,
   isa     => 'DBIx::Class::DeploymentHandler::Databases',
@@ -129,7 +107,8 @@ method _deployment_statements {
   return $wa ? @ret : $ret[0];
 }
 
-method _deploy {
+sub _deploy {
+  my $self = shift;
   my $storage  = $self->storage;
 
   my $deploy = sub {
@@ -159,7 +138,8 @@ method _deploy {
   }
 }
 
-method prepare_install {
+sub prepare_install {
+  my $self = shift;
   my $schema    = $self->schema;
   my $databases = $self->databases;
   my $dir       = $self->upgrade_directory;
@@ -213,7 +193,8 @@ method prepare_install {
   }
 }
 
-method prepare_update($version, $preversion) {
+sub prepare_update {
+  my ($self, $version, $preversion) = @_;
   my $schema    = $self->schema;
   my $databases = $self->databases;
   my $dir       = $self->upgrade_directory;
@@ -334,9 +315,9 @@ method _read_sql_file($file) {
   return \@data;
 }
 
-method _upgrade_single_step {
+sub _upgrade_single_step {
+  my $self = shift;
   my @version_set = @{ shift @_ };
-  my $db_version = $self->db_version;
   my $upgrade_file = $self->_ddl_filename(
     $self->storage->sqlt_type,
     \@version_set,
@@ -349,17 +330,8 @@ method _upgrade_single_step {
     return;
   }
 
-  carp "DB version ($db_version) is lower than the schema version (".$self->schema_version."). Attempting upgrade.\n";
-
   $self->_filedata($self->_read_sql_file($upgrade_file)); # I don't like this --fREW 2010-02-22
-  $self->backup if $self->do_backup;
   $self->schema->txn_do(sub { $self->_do_upgrade });
-
-  $self->version_rs->create({
-    version     => $version_set[-1],
-    # ddl         => $ddl,
-    # upgrade_sql => $upgrade_sql,
-  });
 }
 
 method _do_upgrade { $self->_run_upgrade(qr/.*?/) }
@@ -380,8 +352,6 @@ method _apply_statement($statement) {
   $self->storage->dbh->do($_) or carp "SQL was: $_"
 }
 
-method backup { $self->storage->backup($self->backup_directory) }
-
 __PACKAGE__->meta->make_immutable;
 
 1;