我正在尝试在我的 rails 应用程序中使用 PostgreSQL 触发器。所以我尝试使用这种迁移,其中触发器的执行应该很容易:
-- class AddTriggersToProducts < ActiveRecord::Migration
def self.up
table :products
execute %q{
create trigger trig1 before insert on products for each row
begin
price = price + 5
end;
}
end
def self.down
execute 'DROP TRIGGER trig1'
end
end
但这并没有改变什么。如果我要在这里使用一个,我不知道在哪里编写过程或函数......