Trigger Happy
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
To add a trigger do this:
add_trigger "ai_people",
:on => 'people',
:timing => 'after',
:event => 'insert',
:statement => 'INSERT INTO log (id, timestamp) VALUES (NEW.id, NOW())'
:on => '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.
Posted by Aaron Patterson • Permalink • Leave your Comment »
kamal says:
would that be :event => ‘insert’ ?
Thursday, 1 March 2007 @ 5:52pm
Aaron Patterson says:
You are correct. I’ll fix that. Thanks!
Thursday, 1 March 2007 @ 6:04pm