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.002233';
3             # ABSTRACT: Attach this component to your schema to ensure you stay up to date
4              
5 17     17   931437 use strict;
  17         55  
  17         437  
6 17     17   85 use warnings;
  17         37  
  17         389  
7              
8 17     17   512 use Carp 'carp';
  17         88  
  17         946  
9 17     17   4035 use DBIx::Class::DeploymentHandler::VersionStorage::Standard::VersionResult;
  17         43  
  17         3643  
10              
11             sub attach_version_storage {
12 45     45 0 249 $_[0]->register_class(
13             __VERSION => 'DBIx::Class::DeploymentHandler::VersionStorage::Standard::VersionResult'
14             );
15             }
16              
17             sub connection {
18 45     45 0 167389 my $self = shift;
19 45         623 $self->next::method(@_);
20              
21 45         607001 $self->attach_version_storage;
22              
23 45         15466 my $args = $self->storage->_dbic_connect_attributes;
24              
25 45 50 66     650 unless ( $args->{ignore_version} || $ENV{DBIC_NO_VERSION_CHECK}) {
26 2         13 my $versions = $self->resultset('__VERSION');
27              
28 2 100       865 if (!$versions->version_storage_is_installed) {
    50          
29 1         126 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         2573 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 45         3063 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