我需要在rails中的列上创建一个不区分大小写的索引.我是通过SQL做到的:
execute(
"CREATE UNIQUE INDEX index_users_on_lower_email_index
ON users (lower(email))"
)
Run Code Online (Sandbox Code Playgroud)
这很好用,但在我的schema.rb文件中我有:
add_index "users", [nil],
:name => "index_users_on_lower_email_index",
:unique => true
Run Code Online (Sandbox Code Playgroud)
注意"无".因此,当我尝试克隆数据库以运行测试时,我得到一个明显的错误.我在这里做错了吗?我应该在rails中使用其他一些约定吗?
谢谢您的帮助.