X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FSchema%2FVersioned.pm;h=1e8f39a7d6b613c1ece51a471ac57ebb6547a12e;hb=fd323bf1046faa7de5a8c985268d80ec5b703361;hp=d192d21160af36650e6e6668bedcd3f078b9b406;hpb=8012b15cd056286d84a619882301970c6c3cf3bb;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Schema/Versioned.pm b/lib/DBIx/Class/Schema/Versioned.pm index d192d21..1e8f39a 100644 --- a/lib/DBIx/Class/Schema/Versioned.pm +++ b/lib/DBIx/Class/Schema/Versioned.pm @@ -182,6 +182,8 @@ use base 'DBIx::Class::Schema'; use Carp::Clan qw/^DBIx::Class/; use Time::HiRes qw/gettimeofday/; +use Try::Tiny; +use namespace::clean; __PACKAGE__->mk_classdata('_filedata'); __PACKAGE__->mk_classdata('upgrade_directory'); @@ -503,7 +505,7 @@ sub get_db_version my ($self, $rs) = @_; my $vtable = $self->{vschema}->resultset('Table'); - my $version = eval { + my $version = try { $vtable->search({}, { order_by => { -desc => 'installed' }, rows => 1 } ) ->get_column ('version') ->next; @@ -682,13 +684,13 @@ sub _set_db_version { # This is necessary since there are legitimate cases when upgrades can happen # back to back within the same second. This breaks things since we relay on the # ability to sort by the 'installed' value. The logical choice of an autoinc - # is not possible, as it will break multiple legacy installations. Also it is + # is not possible, as it will break multiple legacy installations. Also it is # not possible to format the string sanely, as the column is a varchar(20). # The 'v' character is added to the front of the string, so that any version # formatted by this new function will sort _after_ any existing 200... strings. my @tm = gettimeofday(); my @dt = gmtime ($tm[0]); - my $o = $vtable->create({ + my $o = $vtable->create({ version => $version, installed => sprintf("v%04d%02d%02d_%02d%02d%02d.%03.0f", $dt[5] + 1900, @@ -724,12 +726,9 @@ sub _source_exists { my ($self, $rs) = @_; - my $c = eval { - $rs->search({ 1, 0 })->count; - }; - return 0 if $@ || !defined $c; + my $c = try { $rs->search({ 1, 0 })->count }; - return 1; + return (defined $c) ? 1 : 0; } 1;