done refactoring
[dbsrgits/DBIx-Class-DeploymentHandler.git] / lib / DBIx / Class / DeploymentHandler / Component.pm
1 package DBIx::Class::DepolymentHandler::Component;
2
3 use strict;
4 use warnings;
5
6 sub connection  {
7   my $self = shift;
8   $self->next::method(@_);
9
10   $args = $_[3] || {};
11
12   return if $args->{ignore_version} || $ENV{DBIC_NO_VERSION_CHECK};
13
14   my $versions = $self->resultset('VersionResult');
15
16   unless($versions->is_installed) {
17           carp "Your DB is currently unversioned. Please call upgrade on your schema to sync the DB.\n";
18           return 1;
19   }
20
21   my $pversion = $versions->db_version;
22
23   return 1 if $pversion eq $self->schema_version;
24
25   carp "Versions out of sync. This is " . $self->schema_version .
26     ", your database contains version $pversion, please call upgrade on your Schema.\n";
27
28   return $self;
29 }
30
31 1;