Commit | Line | Data |
30c3818a |
1 | package DBIx::Class::DeploymentHandler::VersionStorage::Standard::Component; |
12fdd461 |
2 | |
0fa93773 |
3 | # ABSTRACT: Attach this component to your schema to ensure you stay up to date |
4 | |
12fdd461 |
5 | use strict; |
6 | use warnings; |
7 | |
099d6ab0 |
8 | use Carp 'carp'; |
30c3818a |
9 | use DBIx::Class::DeploymentHandler::VersionStorage::Standard::VersionResult; |
0fa32e91 |
10 | |
6bbb6ce7 |
11 | sub attach_version_storage { |
e52174e3 |
12 | $_[0]->register_class( |
13 | __VERSION => 'DBIx::Class::DeploymentHandler::VersionStorage::Standard::VersionResult' |
14 | ); |
0fa32e91 |
15 | } |
099d6ab0 |
16 | |
12fdd461 |
17 | sub connection { |
18 | my $self = shift; |
19 | $self->next::method(@_); |
20 | |
6bbb6ce7 |
21 | $self->attach_version_storage; |
0fa32e91 |
22 | |
099d6ab0 |
23 | my $args = $_[3] || {}; |
12fdd461 |
24 | |
d94ecdd6 |
25 | unless ( $args->{ignore_version} || $ENV{DBIC_NO_VERSION_CHECK}) { |
e52174e3 |
26 | my $versions = $self->resultset('__VERSION'); |
27 | |
28 | if (!$versions->version_storage_is_installed) { |
29 | carp "Your DB is currently unversioned. Please call upgrade on your schema to sync the DB.\n"; |
30 | } elsif ($versions->database_version ne $self->schema_version) { |
31 | carp 'Versions out of sync. This is ' . $self->schema_version . |
32 | ', your database contains version ' . $versions->database_version . ", please call upgrade on your Schema.\n"; |
33 | } |
12fdd461 |
34 | } |
6bbb6ce7 |
35 | |
12fdd461 |
36 | return $self; |
37 | } |
38 | |
39 | 1; |
e52174e3 |
40 | |
41 | # vim: ts=2 sw=2 expandtab |
42 | |
43 | __END__ |
44 | |