frioux / DBIx-Class-DeploymentHandler

https://metacpan.org/pod/DBIx::Class::DeploymentHandler
21 stars 26 forks source link

sqlt_deploy_hook gets called twice #38

Open mrenvoize opened 8 years ago

mrenvoize commented 8 years ago

As the title says, the sqlt_deploy-hook can end up getting called twice, once for the versions tables only it seems and once for everything else.

mrenvoize commented 8 years ago

I overcame it temporarily with the following in my Schema class.. hopefully it helps

use utf8;
package Rebus::Schema;

use strict;
use warnings;

use base 'DBIx::Class::Schema';

our $VERSION = 18;

__PACKAGE__->load_namespaces;

=head1 DEPLOY HOOKS

=head2 rebus triggers

=cut

sub sqlt_deploy_hook {
  my ($self, $sqlt_schema) = @_;

  # Hack to prevent hook being called for a second time (as thus fail) with DeploymentHandler
  return if @{$sqlt_schema->get_tables} == 1 and $sqlt_schema->get_tables->[0]->name eq 'dbix_class_deploymenthandler_versions';
  ...
  index's, triggers, whatever here
  ...
}
mohawk2 commented 5 years ago

Is it your expectation that the hook wouldn't get called for installing the database-version RS? We could just local monkey-patch the hook out in that situation, which seems reasonable.