Add a new column with an index

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

results matching ""

    No results matching ""