I have a table and I'm trying to add a unique index on two columns. Those columns are also indexed. So my question is if I just can remove the indexes who were just for one column or if I have to use all three indexes:
我有一个表,我想在两列上添加一个唯一的索引。这些列也被索引。所以我的问题是,如果我只删除一个列的索引,或者我必须使用这三个索引:
add_index "subscriptions", ["user_id"]
add_index "subscriptions", ["content_id"]
add_index "subscriptions", ["user_id"], ["content_id"], :unique => true
Thanks for your clarification Markus
谢谢你的澄清,马库斯
1 个解决方案
#1
133
add_index :subscriptions, [:user_id, :content_id], unique: true
#1
133
add_index :subscriptions, [:user_id, :content_id], unique: true