Answers for "how to create migration with uniqueness inrails"

1

how to create migration with uniqueness inrails

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 create migration with uniqueness inrails

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

Code answers related to "how to create migration with uniqueness inrails"

Browse Popular Code Answers by Language