Answers for "rails unique in migration"

1

how to add uniqueness in rails migration

class AddEmailToUsers < ActiveRecord::Migration[5.0]
  def change
    add_column :users, :email, :string
    add_index :users, :email, unique: true
  end
end
Posted by: Guest on August-06-2021
1

how to add uniqueness in rails migration

rails generate migration AddEmailToUsers email:string:uniq
Posted by: Guest on August-06-2021

Browse Popular Code Answers by Language