more namespace reorg
[dbsrgits/DBIx-Class-DeploymentHandler.git] / lib / DBIx / Class / DeploymentHandler / Component.pm
index 0c2ef93..fec0e1b 100644 (file)
@@ -1,32 +1,37 @@
-package DBIx::Class::DepolymentHandler::Component;
+package DBIx::Class::DeploymentHandler::Component;
 
 use strict;
 use warnings;
 
 use Carp 'carp';
+use DBIx::Class::DeploymentHandler::VersionResult;
+
+sub set_us_up_the_bomb {
+       my $self = shift;
+
+       $self->register_class(
+               __VERSION => 'DBIx::Class::DeploymentHandler::VersionResult'
+       );
+}
 
 sub connection  {
   my $self = shift;
   $self->next::method(@_);
 
-  my $args = $_[3] || {};
+  $self->set_us_up_the_bomb;
 
-  return if $args->{ignore_version} || $ENV{DBIC_NO_VERSION_CHECK};
+  my $args = $_[3] || {};
 
-  my $versions = $self->resultset('VersionResult');
+  unless ( $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 1;
+        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 1 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;
 }