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