discourse/db/migrate/20171220181249_change_user_emails_primary_index.rb

12 lines
353 B
Ruby
Raw Normal View History

2017-12-21 20:30:26 +08:00
class ChangeUserEmailsPrimaryIndex < ActiveRecord::Migration[5.1]
def up
remove_index :user_emails, [:user_id, :primary]
add_index :user_emails, [:user_id, :primary], unique: true, where: '"primary"'
end
def down
remove_index :user_emails, [:user_id, :primary]
add_index :user_emails, [:user_id, :primary], unique: true
end
end