Posted over 9 years ago. Visible to the public. Repeats. Linked content.

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

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

Copy
def self.up add_column :comments, :user_id, :integer add_index :comments, :user_id end

Owner of this card:

Avatar
Dragos Miron
Last edit:
almost 4 years ago
Tags:
foreign, index, key, migrate, migration
Posted by Dragos Miron to HouseTrip Deck
This website uses short-lived cookies to improve usability.
Accept or learn more