Add a new column with an index

suggest change

To add a new indexed column email to the users table, run the command:

rails generate migration AddEmailToUsers email:string:index

This will generate the following migration:

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

Feedback about page:

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


ActiveRecord migrations:
* Add a new column with an index

Table Of Contents
3 Views
4 ActiveRecord migrations
19 Caching
23 Rails 5
25 Mongoid
26 Gems
55 CSV