使用DataMapper创建MySQL触发器 [英] Creating MySQL triggers using DataMapper

查看:67
本文介绍了使用DataMapper创建MySQL触发器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试自己寻找和解决问题,但到目前为止还没有运气:(

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

我想使用DataMapper(

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

我真的想让触发器成为我的代码版本控制(用于文档和维护)的一部分。 / p>

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

推荐答案

在迁移中只需执行任意SQL

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

当然,这不会太可怕

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

这篇关于使用DataMapper创建MySQL触发器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆