working deprecated bundle
[dbsrgits/DBIx-Class-DeploymentHandler.git] / lib / DBIx / Class / DeploymentHandler / VersionStorage / Deprecated / VersionResultSet.pm
1 package DBIx::Class::DeploymentHandler::VersionStorage::Deprecated::VersionResultSet;
2
3 use strict;
4 use warnings;
5
6 use parent 'DBIx::Class::ResultSet';
7
8 use Try::Tiny;
9 use Time::HiRes 'gettimeofday';
10
11 sub version_storage_is_installed {
12   my $self = shift;
13   try { $self->next; 1 } catch { undef }
14 }
15
16 sub database_version {
17   my $self = shift;
18   $self->search(undef, {
19     order_by => { -desc => 'installed' },
20     rows => 1
21   })->get_column('version')->next;
22 }
23
24 # this is why it's deprecated guys... Serially.
25 sub create {
26   my $self = shift;
27   my $args = shift;
28
29   my @tm = gettimeofday();
30   my @dt = gmtime ($tm[0]);
31
32   $self->next::method({
33     %{$args},
34     installed => sprintf("v%04d%02d%02d_%02d%02d%02d.%03.0f",
35       $dt[5] + 1900,
36       $dt[4] + 1,
37       $dt[3],
38       $dt[2],
39       $dt[1],
40       $dt[0],
41       $tm[1] / 1000, # convert to millisecs, format as up/down rounded int above
42     ),
43   });
44 }
45
46 1;
47
48 __END__
49
50 vim: ts=2 sw=2 expandtab