开发者

Creating MySQL triggers using DataMapper

开发者 https://www.devze.com 2023-02-17 14:10 出处:网络
I\'ve been trying to sear开发者_C百科ch 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've been trying to sear开发者_C百科ch 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).


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

0

精彩评论

暂无评论...
验证码 换一张
取 消