various doc
[dbsrgits/DBIx-Class-DeploymentHandler.git] / lib / DBIx / Class / DeploymentHandler / VersionStorage / Deprecated / VersionResultSet.pm
1 package DBIx::Class::DeploymentHandler::VersionStorage::Deprecated::VersionResultSet;
2
3 # ABSTRACT: (DEPRECATED) 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 use Time::HiRes 'gettimeofday';
12
13 sub version_storage_is_installed {
14   my $self = shift;
15   try { $self->next; 1 } catch { undef }
16 }
17
18 sub database_version {
19   my $self = shift;
20   $self->search(undef, {
21     order_by => { -desc => 'installed' },
22     rows => 1
23   })->get_column('version')->next;
24 }
25
26 # this is why it's deprecated guys... Serially.
27 sub create {
28   my $self = shift;
29   my $args = shift;
30
31   my @tm = gettimeofday();
32   my @dt = gmtime ($tm[0]);
33
34   $self->next::method({
35     %{$args},
36     installed => sprintf("v%04d%02d%02d_%02d%02d%02d.%03.0f",
37       $dt[5] + 1900,
38       $dt[4] + 1,
39       $dt[3],
40       $dt[2],
41       $dt[1],
42       $dt[0],
43       $tm[1] / 1000, # convert to millisecs, format as up/down rounded int above
44     ),
45   });
46 }
47
48 1;
49
50 # vim: ts=2 sw=2 expandtab
51
52 __END__
53
54 =method version_storage_is_installed
55
56 True if (!!!) the version storage has been installed
57
58 =method database_version
59
60 The version of the database
61
62 =method create
63
64 Overridden to default C<installed> to the current time. (take a look, it's yucky)