I'm using Rails 5 and the above answers work great; here's another way that also worked for me (the table name is :people
and the column name is :email_address
)
class AddIndexToEmailAddress < ActiveRecord::Migration[5.0]
def change
change_table :people do |t|
t.index :email_address, unique: true
end
end
end