From: Arthur Axel 'fREW' Schmidt Date: Tue, 23 Feb 2010 20:58:39 +0000 (-0600) Subject: "simplify" connect code X-Git-Tag: v0.001000_01~134 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d94ecdd6e134decf0a31a856c6353c5e26d98bfb;p=dbsrgits%2FDBIx-Class-DeploymentHandler.git "simplify" connect code --- diff --git a/lib/DBIx/Class/DeploymentHandler/Component.pm b/lib/DBIx/Class/DeploymentHandler/Component.pm index ea7a9ae..fec0e1b 100644 --- a/lib/DBIx/Class/DeploymentHandler/Component.pm +++ b/lib/DBIx/Class/DeploymentHandler/Component.pm @@ -22,22 +22,16 @@ sub connection { my $args = $_[3] || {}; - return if $args->{ignore_version} || $ENV{DBIC_NO_VERSION_CHECK}; - - my $versions = $self->resultset('__VERSION'); - - unless($versions->is_installed) { - carp "Your DB is currently unversioned. Please call upgrade on your schema to sync the DB.\n"; - return $self; + unless ( $args->{ignore_version} || $ENV{DBIC_NO_VERSION_CHECK}) { + my $versions = $self->resultset('__VERSION'); + + if (!$versions->is_installed) { + carp "Your DB is currently unversioned. Please call upgrade on your schema to sync the DB.\n"; + } elsif ($versions->db_version ne $self->schema_version) { + carp 'Versions out of sync. This is ' . $self->schema_version . + ', your database contains version ' . $versions->db_version . ", please call upgrade on your Schema.\n"; + } } - - my $pversion = $versions->db_version; - - return $self if $pversion eq $self->schema_version; - - carp "Versions out of sync. This is " . $self->schema_version . - ", your database contains version $pversion, please call upgrade on your Schema.\n"; - return $self; }