Add indexes on foreign keys when you create a migration (with foreign key)

Updated . Posted . Visible to the public. Repeats.

Whenever you make a migration to add a foreign key, you should also add an index for it

  def self.up
    add_column :comments, :user_id, :integer
    add_index :comments, :user_id
  end
Dragos Miron
Last edit
Posted by Dragos Miron to HouseTrip Deck (2012-08-23 11:13)