Trigger Happy 2

Posted by Aaron Patterson on March 01, 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.

Trackbacks

Use this link to trackback from your own site.

Comments

Leave a response

  1. kamal Thu, 01 Mar 2007 17:52:40 UTC

    would that be :event => ‘insert’ ?

  2. Aaron Patterson Thu, 01 Mar 2007 18:04:07 UTC

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

Comments

Check Spelling
Activate Spell Check while Typing