After a few hours of working in a new rails project i successfully configured a has_many :thru association with the following migration
class CreateEdits < ActiveRecord::Migration
def change
create_table :edits do |t|
t.references :user
t.references :post
t.string :action
t.text :summary
t.timestamps
end
end
end
Now after reading further on the topic discovered that apparently i should have added
add_index :edits, [:user_id, :post_id], unique: true
But the rails guides on this topic mention nothing about the need to index these columns. So id like to know if theres really a need for me to create a new migration to add such indexes. I'm new in the whole rails and coding thing so i'd love to know if this would be essential in a production environment or not,as for me to become accustomed to the best practices along the way.
Thanks in advance.