3 One of the reasons for the absurd level of flexibility that
4 L<DBIx::Class::DeploymentHandler> is so that you can do things that we did not
5 originally anticipate. Surprisingly, I never added a method to change the
6 table for the version storage. That's fine though, the following recipe
7 shows how one can do it in style:
11 package MyApp::Schema::DBICDHStorage;
13 extends 'DBIx::Class::DeploymentHandler::VersionStorage::Standard';
15 sub _build_version_rs {
16 $_[0]->schema->register_class(
18 'MyApp::Schema::DBICDHStorageResult'
20 $_[0]->schema->resultset('__VERSION')
24 __PACKAGE__->meta->make_immutable;
27 There's not a whole lot special there. The only real bit of code to point out
28 is the C<register_class> call. We make sure to point C<__VERSION> to the
29 result class that we will define next.
31 =head2 Version Result Class
33 package MyApp::Schema::DBICDHStorageResult;
34 use parent 'DBIx::Class::DeploymentHandler::VersionStorage::Standard::VersionResult';
35 __PACKAGE__->table('fl_bench_journal_versions');
38 As you can see, this is almost silly how simple it is, we just change the
39 table being set on the original result.
41 =head2 Our very own DeploymentHandler
43 package MyApp::Schema::DeploymentHandler;
45 extends 'DBIx::Class::DeploymentHandler::Dad';
47 # a single with would be better, but we can't do that
48 # see: http://rt.cpan.org/Public/Bug/Display.html?id=46347
49 with 'DBIx::Class::DeploymentHandler::WithApplicatorDumple' => {
50 interface_role => 'DBIx::Class::DeploymentHandler::HandlesDeploy',
51 class_name => 'DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator',
52 delegate_name => 'deploy_method',
53 attributes_to_assume => ['schema'],
54 attributes_to_copy => [qw( databases upgrade_directory sql_translator_args )],
56 'DBIx::Class::DeploymentHandler::WithApplicatorDumple' => {
57 interface_role => 'DBIx::Class::DeploymentHandler::HandlesVersioning',
58 class_name => 'DBIx::Class::DeploymentHandler::VersionHandler::Monotonic',
59 delegate_name => 'version_handler',
60 attributes_to_assume => [qw( database_version schema_version to_version )],
62 'DBIx::Class::DeploymentHandler::WithApplicatorDumple' => {
63 interface_role => 'DBIx::Class::DeploymentHandler::HandlesVersionStorage',
64 class_name => 'MyApp::Schema::DBICDHStorage',
65 delegate_name => 'version_storage',
66 attributes_to_assume => ['schema'],
68 with 'DBIx::Class::DeploymentHandler::WithReasonableDefaults';
70 sub prepare_version_storage_install {
73 $self->prepare_resultsource_install(
74 $self->version_storage->version_rs->result_source
78 sub install_version_storage {
81 $self->install_resultsource(
82 $self->version_storage->version_rs->result_source
87 $_[0]->prepare_deploy;
88 $_[0]->prepare_version_storage_install;
92 __PACKAGE__->meta->make_immutable;