Reputation: 4038
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
Upvotes: 123
Views: 54358
Reputation: 46914
add_index :subscriptions, [:user_id, :content_id], unique: true
Upvotes: 242