Creating MySQL triggers using DataMapper

你说的曾经没有我的故事 提交于 2019-12-25 03:32:47

问题


I've been trying to search and figure this on my own, but no luck so far :(

I'd like to create MySQL triggers using DataMapper (or any other Ruby db adapter). Is this possible?

I'd really like to have the triggers become part of my code versioning (for documentation and maintenance).


回答1:


Simply execute arbitrary SQL in your migrations

migration 1, :create_people_table do
  up do
    execute 'CREATE TRIGGER ...'
  end
  down do
    execute 'DROP TRIGGER ...'
  end
end

Of course, it won't be terribly portable.

http://rubydoc.info/gems/dm-migrations/1.1.0/DataMapper/Migration:execute



来源:https://stackoverflow.com/questions/5336424/creating-mysql-triggers-using-datamapper

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!