X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FDeploymentHandler%2FCookbook%2FCustomResultSource.pod;h=a1ad2a660d6f0732f4808ed4d6125d6e63b0aa7a;hb=91adde755e5808a1ec12bcf00e683e3754964cc9;hp=b1bba7e6fac29ccc466dca750001179317288e55;hpb=6933f31f65b080a7d3ffdc1e1dc46b742445e75f;p=dbsrgits%2FDBIx-Class-DeploymentHandler.git diff --git a/lib/DBIx/Class/DeploymentHandler/Cookbook/CustomResultSource.pod b/lib/DBIx/Class/DeploymentHandler/Cookbook/CustomResultSource.pod index b1bba7e..a1ad2a6 100644 --- a/lib/DBIx/Class/DeploymentHandler/Cookbook/CustomResultSource.pod +++ b/lib/DBIx/Class/DeploymentHandler/Cookbook/CustomResultSource.pod @@ -1,11 +1,21 @@ - package MyApp::Schema::JournalStorage; +=pod + +One of the reasons for the absurd level of flexibility that +L is so that you can do things that we did not +originally anticipate. Surprisingly, I never added a method to change the +table for the version storage. That's fine though, the following recipe +shows how one can do it in style: + +=head2 Version Storage + + package MyApp::Schema::DBICDHStorage; use Moose; extends 'DBIx::Class::DeploymentHandler::VersionStorage::Standard'; sub _build_version_rs { $_[0]->schema->register_class( __VERSION => - 'FL::Bench::Schema::JournalTable' + 'MyApp::Schema::DBICDHStorageResult' ); $_[0]->schema->resultset('__VERSION') } @@ -14,12 +24,23 @@ __PACKAGE__->meta->make_immutable; 1; - package MyApp::Schema::JournalTable; +There's not a whole lot special there. The only real bit of code to point out +is the C call. We make sure to point C<__VERSION> to the +result class that we will define next. + +=head2 Version Result Class + + package MyApp::Schema::DBICDHStorageResult; use parent 'DBIx::Class::DeploymentHandler::VersionStorage::Standard::VersionResult'; __PACKAGE__->table('fl_bench_journal_versions'); 1; - package MyApp::Schema::Journal; +As you can see, this is almost silly how simple it is, we just change the +table being set on the original result. + +=head2 Our very own DeploymentHandler + + package MyApp::Schema::DeploymentHandler; use Moose; extends 'DBIx::Class::DeploymentHandler::Dad'; @@ -30,7 +51,7 @@ class_name => 'DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator', delegate_name => 'deploy_method', attributes_to_assume => ['schema'], - attributes_to_copy => [qw( databases upgrade_directory sql_translator_args )], + attributes_to_copy => [qw( databases script_directory sql_translator_args )], }, 'DBIx::Class::DeploymentHandler::WithApplicatorDumple' => { interface_role => 'DBIx::Class::DeploymentHandler::HandlesVersioning', @@ -40,7 +61,7 @@ }, 'DBIx::Class::DeploymentHandler::WithApplicatorDumple' => { interface_role => 'DBIx::Class::DeploymentHandler::HandlesVersionStorage', - class_name => 'MyApp::Schema::JournalStorage', + class_name => 'MyApp::Schema::DBICDHStorage', delegate_name => 'version_storage', attributes_to_assume => ['schema'], };