Answers for "rails add index migration"

0

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
Posted by: Guest on February-14-2020
5

rails g migration add columns

$ rails generate migration AddDetailsToProducts part_number:string price:decimal
Posted by: Guest on August-11-2020

Code answers related to "rails add index migration"

Browse Popular Code Answers by Language