ruby on rails migration index code example
Example 1: change column rails example
def change
change_column(:table_name, :column_name, :new_type)
end
Example 2: rails g migration add columns
$ rails generate migration AddDetailsToProducts part_number:string price:decimal
Example 3: 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