initial VersionStorage commit
Arthur Axel 'fREW' Schmidt [Wed, 17 Mar 2010 05:48:12 +0000 (00:48 -0500)]
lib/DBIx/Class/DeploymentHandler/HandlesVersionStorage.pm [new file with mode: 0644]
lib/DBIx/Class/DeploymentHandler/VersionStorage/Standard.pm [new file with mode: 0644]
lib/DBIx/Class/DeploymentHandler/WithStandardVersionStorage.pm [new file with mode: 0644]

diff --git a/lib/DBIx/Class/DeploymentHandler/HandlesVersionStorage.pm b/lib/DBIx/Class/DeploymentHandler/HandlesVersionStorage.pm
new file mode 100644 (file)
index 0000000..3735866
--- /dev/null
@@ -0,0 +1,13 @@
+package DBIx::Class::DeploymentHandler::HandlesVersionStorage;
+use Moose::Role;
+
+requires 'database_version';
+requires 'add_database_version';
+requires 'install_version_storage';
+requires 'version_storage_is_installed';
+
+1;
+
+__END__
+
+vim: ts=2 sw=2 expandtab
diff --git a/lib/DBIx/Class/DeploymentHandler/VersionStorage/Standard.pm b/lib/DBIx/Class/DeploymentHandler/VersionStorage/Standard.pm
new file mode 100644 (file)
index 0000000..0d9cd88
--- /dev/null
@@ -0,0 +1,34 @@
+package DBIx::Class::DeploymentHandler::VersionStorage::Standard;
+use Moose;
+use Method::Signatures::Simple;
+
+has schema => (
+  isa      => 'DBIx::Class::Schema',
+  is       => 'ro',
+  required => 1,
+);
+
+has version_rs => (
+  isa        => 'DBIx::Class::ResultSet',
+  is         => 'ro',
+  lazy_build => 1, # builder comes from another role...
+                   # which is... probably not how we want it
+  handles    => [qw( database_version version_storage_is_installed )],
+);
+
+with 'DBIx::Class::DeploymentHandler::HandlesVersionStorage';
+
+sub _build_version_rs {
+   $_[0]->schema->set_us_up_the_bomb;
+   $_[0]->schema->resultset('__VERSION')
+}
+
+sub add_database_version { $_[0]->version_rs->create($_[1]) }
+
+sub install_version_storage { die }
+
+1;
+
+__END__
+
+vim: ts=2 sw=2 expandtab
diff --git a/lib/DBIx/Class/DeploymentHandler/WithStandardVersionStorage.pm b/lib/DBIx/Class/DeploymentHandler/WithStandardVersionStorage.pm
new file mode 100644 (file)
index 0000000..afcc1d5
--- /dev/null
@@ -0,0 +1,22 @@
+package DBIx::Class::DeploymentHandler::WithStandardVersionStorage;
+use Moose::Role;
+
+use DBIx::Class::DeploymentHandler::VersionStorage::Standard;
+
+has version_storage => (
+  does => 'DBIx::Class::DeploymentHandler::HandlesVersionStorage',
+  is  => 'ro',
+  lazy_build => 1,
+  handles =>  'DBIx::Class::DeploymentHandler::HandlesVersionStorage',
+);
+
+sub _build_version_storage {
+  DBIx::Class::DeploymentHandler::VersionStorage::Standard
+    ->new({ schema => $_[0]->schema });
+}
+
+1;
+
+__END__
+
+vim: ts=2 sw=2 expandtab