txn_Wrap for upgrades
[dbsrgits/DBIx-Class-DeploymentHandler.git] / lib / DBIx / Class / DeploymentHandler / Component.pm
CommitLineData
0fa32e91 1package DBIx::Class::DeploymentHandler::Component;
12fdd461 2
3use strict;
4use warnings;
5
099d6ab0 6use Carp 'carp';
0fa32e91 7use DBIx::Class::DeploymentHandler::VersionResult;
8
9sub set_us_up_the_bomb {
10 my $self = shift;
11
12 $self->register_class(
13 __VERSION => 'DBIx::Class::DeploymentHandler::VersionResult'
14 );
15}
099d6ab0 16
12fdd461 17sub connection {
18 my $self = shift;
19 $self->next::method(@_);
20
0fa32e91 21 $self->set_us_up_the_bomb;
22
099d6ab0 23 my $args = $_[3] || {};
12fdd461 24
d94ecdd6 25 unless ( $args->{ignore_version} || $ENV{DBIC_NO_VERSION_CHECK}) {
26 my $versions = $self->resultset('__VERSION');
27
28 if (!$versions->is_installed) {
29 carp "Your DB is currently unversioned. Please call upgrade on your schema to sync the DB.\n";
30 } elsif ($versions->db_version ne $self->schema_version) {
31 carp 'Versions out of sync. This is ' . $self->schema_version .
32 ', your database contains version ' . $versions->db_version . ", please call upgrade on your Schema.\n";
33 }
12fdd461 34 }
12fdd461 35 return $self;
36}
37
381;