Commit | Line | Data |
0fa32e91 |
1 | package DBIx::Class::DeploymentHandler::Component; |
12fdd461 |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
099d6ab0 |
6 | use Carp 'carp'; |
0fa32e91 |
7 | use DBIx::Class::DeploymentHandler::VersionResult; |
8 | |
9 | sub 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 |
17 | sub 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 | |
25 | return if $args->{ignore_version} || $ENV{DBIC_NO_VERSION_CHECK}; |
26 | |
0fa32e91 |
27 | my $versions = $self->resultset('__VERSION'); |
12fdd461 |
28 | |
29 | unless($versions->is_installed) { |
30 | carp "Your DB is currently unversioned. Please call upgrade on your schema to sync the DB.\n"; |
0fa32e91 |
31 | return $self; |
12fdd461 |
32 | } |
33 | |
34 | my $pversion = $versions->db_version; |
35 | |
0fa32e91 |
36 | return $self if $pversion eq $self->schema_version; |
12fdd461 |
37 | |
38 | carp "Versions out of sync. This is " . $self->schema_version . |
39 | ", your database contains version $pversion, please call upgrade on your Schema.\n"; |
40 | |
41 | return $self; |
42 | } |
43 | |
44 | 1; |