【发布时间】:2012-10-07 11:13:47
【问题描述】:
我有一些在我的迁移中创建触发器和函数的原始 sql 语句。它们不会在测试中调用。
如何使用正常迁移来设置测试数据库?为什么这不是默认方法?
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-3 testing rails-migrations
我有一些在我的迁移中创建触发器和函数的原始 sql 语句。它们不会在测试中调用。
如何使用正常迁移来设置测试数据库?为什么这不是默认方法?
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-3 testing rails-migrations
原因是测试数据库是从 schema.rb 文件恢复的。而且 Schema 转储不会创建过程、函数、fkeys 等。原因是 Rails 不鼓励使用它们。但是,您可以将架构转储格式更改为 sql。
config.active_record.schema_format = :sql
请参阅以下主题Why does rake db:migrate in Rails not add functions to the schema file?
【讨论】: