How can I remove a unique constraint from a database column in Rails?
You must remove your index with:
remove_index :profile_pictures, :picture_id
and add it again with:
add_index :profile_pictures, :picture_id
ActiveRecord::Migration
add_index :profile_pictures, :picture_id, unique: true
So update your index to:
remove_index :profile_pictures, :picture_id
add_index :profile_pictures, :picture_id
I'm guessing this is it.
There is a problem with the accepted answer: Rollbacks don't work correctly as the unique index is not restored.
You could try this instead:
reversible do |dir|
dir.up do
remove_index :profile_pictures, :picture_id
add_index :profile_pictures, :picture_id
end
dir.down do
remove_index :profile_pictures, :picture_id
add_index :profile_pictures, :picture_id, unique: true
end
end