Trying to execute this statement in a rails migration to generate a multi column unique constraint/index:
add_index :contributors, [:project_id, :user_id], :unique=>true
I've also tried providing an optional :name to the method, but still getting the failure. There are no existing keys in this table
Mysql::Error: Duplicate entry '5-9' for key 'distinct_user_and_project': CREATE UNIQUE INDEX `distinct_user_and_project` ON `contributors` (`project_id`, `user_id`)
How do I create this short of using execute and straight sql? Thanks.
Its clearly in error (Duplicate entry '5-9'
) that your data is not unique so You can't add such index there
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With