restructure namespace
[dbsrgits/DBIx-Class-DeploymentHandler.git] / lib / DBIx / Class / DeploymentHandler / VersionStorage / Standard / VersionResultSet.pm
diff --git a/lib/DBIx/Class/DeploymentHandler/VersionStorage/Standard/VersionResultSet.pm b/lib/DBIx/Class/DeploymentHandler/VersionStorage/Standard/VersionResultSet.pm
new file mode 100644 (file)
index 0000000..52d73ec
--- /dev/null
@@ -0,0 +1,23 @@
+package DBIx::Class::DeploymentHandler::VersionStorage::Standard::VersionResultSet;
+
+use strict;
+use warnings;
+
+use parent 'DBIx::Class::ResultSet';
+
+use Try::Tiny;
+
+sub version_storage_is_installed {
+  my $self = shift;
+  try { $self->next; 1} catch { undef }
+}
+
+sub database_version {
+  my $self = shift;
+  $self->search(undef, {
+    order_by => { -desc => 'installed' },
+    rows => 1
+  })->get_column('version')->next || 0;
+}
+
+1;