move some general comments to a general role, along with the interface, and initial...
[dbsrgits/DBIx-Class-DeploymentHandler.git] / lib / DBIx / Class / DeploymentHandler / DatabaseToSchemaVersions.pm
index 0c4a249..eb7063f 100644 (file)
@@ -2,29 +2,26 @@ package DBIx::Class::DeploymentHandler::DatabaseToSchemaVersions;
 use Moose;
 use Method::Signatures::Simple;
 
-has schema => (
-  isa      => 'DBIx::Class::Schema',
-  is       => 'ro',
-  required => 1,
-  handles => [qw( ddl_filename schema_version )],
-);
+with 'DBIx::Class::DeploymentHandler::HandlesVersioning';
 
-has version_rs => (
-  isa        => 'DBIx::Class::ResultSet',
-  is         => 'ro',
-  lazy_build => 1,
-  handles    => [qw( is_installed db_version )],
+has once => (
+  is      => 'rw',
+  isa     => 'Bool',
+  default => undef,
 );
 
-method _build_version_rs {
-   $self->schema->set_us_up_the_bomb;
-   $self->schema->resultset('__VERSION')
-}
+sub next_version_set {
+  my $self = shift;
+  return undef
+    if $self->once;
 
-method ordered_schema_versions {
-  ( $self->db_version, $self->schema_version)
+  $self->once(!$self->once);
+  return undef
+    if $self->db_version eq $self->to_version;
+  return [$self->db_version, $self->to_version];
 }
 
+
 __PACKAGE__->meta->make_immutable;
 
 1;