Add an unique column to a table

suggest change

To add a new unique column email to users, run the following command:

rails generate migration AddEmailToUsers email:string:uniq

This will create the following migration:

class AddEmailToUsers < ActiveRecord::Migration[5.0]
  def change
    add_column :users, :email, :string
    add_index :users, :email, unique: true
  end
end

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents