rails add index code example
Example 1: how do I add index's to a migration in rails
rails generate migration AddUser_idColumnToTable user_id:string.
class AddIndexToTable < ActiveRecord::Migration
def change
add_index :table, :user_id
end
end
Example 2: rails add index from console
ActiveRecord::Migration.add_column :table_name, :field_name, :field_type