From: Arthur Axel 'fREW' Schmidt Date: Wed, 17 Mar 2010 05:48:12 +0000 (-0500) Subject: initial VersionStorage commit X-Git-Tag: v0.001000_01~99 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits%2FDBIx-Class-DeploymentHandler.git;a=commitdiff_plain;h=0905dc0e9b45f555ae9217e163132cc49a5eaf23 initial VersionStorage commit --- diff --git a/lib/DBIx/Class/DeploymentHandler/HandlesVersionStorage.pm b/lib/DBIx/Class/DeploymentHandler/HandlesVersionStorage.pm new file mode 100644 index 0000000..3735866 --- /dev/null +++ b/lib/DBIx/Class/DeploymentHandler/HandlesVersionStorage.pm @@ -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 index 0000000..0d9cd88 --- /dev/null +++ b/lib/DBIx/Class/DeploymentHandler/VersionStorage/Standard.pm @@ -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 index 0000000..afcc1d5 --- /dev/null +++ b/lib/DBIx/Class/DeploymentHandler/WithStandardVersionStorage.pm @@ -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