[CDBI] How can you temporarily turn off all triggers for a class?

Matt S Trout dbix-class at trout.me.uk
Tue Jan 31 19:06:40 GMT 2006

On Tue, Jan 31, 2006 at 12:42:50PM -0600, Peter Speltz wrote:
> I want to render all the triggers in a class ineffective for the
> duration of a sub routine.  Anyone have a good idiom for this? In the
> data migration script, the triggers are getting in the way (creating
> things that already exist and need to be migrated and such).

In your base class

use vars qw/$NO_TRIGGERS/;

sub call_trigger {
  return if $NO_TRIGGERS;
  return shift->SUPER::call_trigger(@_);

local $My::Base::Class::NO_TRIGGERS = 1;

     Matt S Trout       Offering custom development, consultancy and support
  Technical Director    contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

 + Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +

More information about the ClassDBI mailing list