Check out example codes for "how do I add index's to a migration in rails". It will help you in understanding the concepts better.
Code Example 1
rails generate migration AddUser_idColumnToTable user_id:string.
class AddIndexToTable < ActiveRecord::Migration
def change
add_index :table, :user_id
end
end
Learn ReactJs, React Native from akashmittal.com