Subject: | Postgres Incompatibility |
Date: | Mon, 21 Sep 2015 16:56:10 +0100 |
To: | bug-DBIx-Migration [...] rt.cpan.org |
From: | Steven Jenkin <sjenkin [...] venda.com> |
= Environment Info:
* Distribution name and version: DBIx::Migration-0.0.7
* Perl version: 5.16.2
* Postgres version 9.4.1
* Operating System vendor and version: Linux 2.6.32-504.1.3.el6.x86_64 1 SMP
DBIx::Migration always generates a
"Database is at version 1 , couldn't migrate to 2”
error when used against a Postgres database. This is due to the version being stored as a CHAR(64) and therefore being padded with spaces. This space-padded value is then string compared to the expected value and will never match.
The following fix appears to correct this:
diff --git a/lib/DBIx/Migration.pm b/lib/DBIx/Migration.pm
index a4c602d..3f1b164 100644
--- a/lib/DBIx/Migration.pm
+++ b/lib/DBIx/Migration.pm
@@ -76,7 +76,7 @@ sub migrate {
$self->_connect;
$wanted = $self->_newest unless defined $wanted;
my $version = $self->_version;
- if ( defined $version && ( $wanted eq $version ) ) {
+ if ( defined $version && ( $wanted == $version ) ) {
print "Database is already at version $wanted\n" if $self->debug;
return 1;
}