initial cut of 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
28   my @tm = gettimeofday();
29   my @dt = gmtime ($tm[0]);
30
31   $self->next::method({
32     version => $version,
33     installed => sprintf("v%04d%02d%02d_%02d%02d%02d.%03.0f",
34       $dt[5] + 1900,
35       $dt[4] + 1,
36       $dt[3],
37       $dt[2],
38       $dt[1],
39       $dt[0],
40       $tm[1] / 1000, # convert to millisecs, format as up/down rounded int above
41     ),
42   });
43 }
44
45 1;
46
47 __END__
48
49 vim: ts=2 sw=2 expandtab