File Coverage

blib/lib/DBIx/Class/DeploymentHandler/VersionStorage/Standard/Component.pm
Criterion Covered Total %
statement 23 23 100.0
branch 4 6 66.6
condition 2 3 66.6
subroutine 6 6 100.0
pod 0 2 0.0
total 35 40 87.5


line stmt bran cond sub pod time code
1             package DBIx::Class::DeploymentHandler::VersionStorage::Standard::Component;
2             $DBIx::Class::DeploymentHandler::VersionStorage::Standard::Component::VERSION = '0.002232';
3             # ABSTRACT: Attach this component to your schema to ensure you stay up to date
4              
5 16     16   997595 use strict;
  16         58  
  16         463  
6 16     16   261 use warnings;
  16         45  
  16         484  
7              
8 16     16   100 use Carp 'carp';
  16         48  
  16         918  
9 16     16   3907 use DBIx::Class::DeploymentHandler::VersionStorage::Standard::VersionResult;
  16         46  
  16         3846  
10              
11             sub attach_version_storage {
12 40     40 0 239 $_[0]->register_class(
13             __VERSION => 'DBIx::Class::DeploymentHandler::VersionStorage::Standard::VersionResult'
14             );
15             }
16              
17             sub connection {
18 40     40 0 178527 my $self = shift;
19 40         229 $self->next::method(@_);
20              
21 40         622547 $self->attach_version_storage;
22              
23 40         15617 my $args = $self->storage->_dbic_connect_attributes;
24              
25 40 50 66     656 unless ( $args->{ignore_version} || $ENV{DBIC_NO_VERSION_CHECK}) {
26 2         16 my $versions = $self->resultset('__VERSION');
27              
28 2 100       1124 if (!$versions->version_storage_is_installed) {
    50          
29 1         141 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 1         3193 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             }
34             }
35              
36 40         4311 return $self;
37             }
38              
39             1;
40              
41             # vim: ts=2 sw=2 expandtab
42              
43             __END__
44              
45             =pod
46              
47             =head1 NAME
48              
49             DBIx::Class::DeploymentHandler::VersionStorage::Standard::Component - Attach this component to your schema to ensure you stay up to date
50              
51             =head1 AUTHOR
52              
53             Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
54              
55             =head1 COPYRIGHT AND LICENSE
56              
57             This software is copyright (c) 2019 by Arthur Axel "fREW" Schmidt.
58              
59             This is free software; you can redistribute it and/or modify it under
60             the same terms as the Perl 5 programming language system itself.
61              
62             =cut