Trigger Happy

Posted by – March 1, 2007

I’ve just released “Trigger Happy“, a rails plugin that adds support for triggers in your Active Record Migrations. To install the plugin just do this:


script/plugin install svn://rubyforge.org/var/svn/artriggers/trunk/trigger_happy
[/sourcecode]

To add a trigger do this:

add_trigger "ai_people",
  :o n         => 'people',
  :timing     => 'after',
  :event      => 'insert',
  :statement  => 'INSERT INTO log (id, timestamp) VALUES (NEW.id, NOW())'

To drop a trigger do this:

drop_trigger "ai_people"

It only supports mysql for now, but I plan on having other database supported in the future.

2 Comments on Trigger Happy

  1. kamal says:

    would that be :event => ‘insert’ ?

  2. You are correct. I’ll fix that. Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>