Answers for "uniqueness true in migration rails"

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

Code answers related to "uniqueness true in migration rails"

Browse Popular Code Answers by Language