Tenderlove Making

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:

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())'

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.

« go back