Ruby on Rails - adding a new column with an index in ruby on rails - ruby on rails tutorial - rails guides - rails tutorial - ruby rails
To add a new indexed column email to the users table, run the command:
rails generate migration AddEmailToUsers email:string:index
Clicking "Copy Code" button will copy the code into the clipboard - memory. Please paste(Ctrl+V) it in your destination. The code will get pasted. Happy coding from Wikitechy - ruby on rails tutorial - rails guides - ruby rails - rubyonrails - learn ruby on rails - team
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