Answers for "rails add index"

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
0

rails add index from console

ActiveRecord::Migration.add_column :table_name, :field_name, :field_type
Posted by: Guest on November-27-2020

Code answers related to "rails add index"

Browse Popular Code Answers by Language