Use ->count instead of ->next to check if version storage is deployed
[dbsrgits/DBIx-Class-DeploymentHandler.git] / lib / DBIx / Class / DeploymentHandler / VersionStorage / Standard / VersionResultSet.pm
1 package DBIx::Class::DeploymentHandler::VersionStorage::Standard::VersionResultSet;
2
3 # ABSTRACT: Predefined searches to find what you want from the version storage
4
5 use strict;
6 use warnings;
7
8 use parent 'DBIx::Class::ResultSet';
9
10 use Try::Tiny;
11
12 sub version_storage_is_installed {
13   my $self = shift;
14   try { $self->count; 1 } catch { undef }
15 }
16
17 sub database_version {
18   my $self = shift;
19   $self->search(undef, {
20     order_by => { -desc => 'id' },
21     rows => 1
22   })->get_column('version')->next;
23 }
24
25 1;
26
27 # vim: ts=2 sw=2 expandtab
28
29 __END__
30
31 =method version_storage_is_installed
32
33 True if (!!!) the version storage has been installed
34
35 =method database_version
36
37 The version of the database