take out silly comments
[dbsrgits/DBIx-Class-DeploymentHandler.git] / lib / DBIx / Class / DeploymentHandler / VersionHandler / ExplicitVersions.pm
index c87b36e..eb01339 100644 (file)
@@ -16,10 +16,9 @@ has database_version => (
   required => 1,
 );
 
-has to_version => ( # configuration
+has to_version => (
   is         => 'ro',
-  lazy_build => 1, # builder comes from another role...
-                   # which is... probably not how we want it
+  lazy_build => 1,
 );
 
 sub _build_to_version { $_[0]->schema_version }
@@ -53,6 +52,7 @@ has _version_idx => (
 );
 
 sub _inc_version_idx { $_[0]->_version_idx($_[0]->_version_idx + 1 ) }
+sub _dec_version_idx { $_[0]->_version_idx($_[0]->_version_idx - 1 ) }
 
 sub _build__version_idx {
   my $self = shift;
@@ -80,6 +80,21 @@ sub next_version_set {
   ];
 }
 
+sub previous_version_set {
+  my $self = shift;
+  return undef
+    if $self->ordered_versions->[$self->_version_idx] eq $self->database_version;
+
+  # this should never get in infinite loops because we ensure
+  # that the database version is in the list in the version_idx
+  # builder
+  my $next_idx = $self->_dec_version_idx;
+  return [
+    $self->ordered_versions->[$next_idx - 1],
+    $self->ordered_versions->[$next_idx    ],
+  ];
+}
+
 __PACKAGE__->meta->make_immutable;
 
 1;