diff options
Diffstat (limited to 'activerecord/lib/rails')
-rw-r--r-- | activerecord/lib/rails/generators/active_record/model/templates/migration.rb | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/activerecord/lib/rails/generators/active_record/model/templates/migration.rb b/activerecord/lib/rails/generators/active_record/model/templates/migration.rb index 70e064be21..7d4e1a7404 100644 --- a/activerecord/lib/rails/generators/active_record/model/templates/migration.rb +++ b/activerecord/lib/rails/generators/active_record/model/templates/migration.rb @@ -8,6 +8,10 @@ class <%= migration_class_name %> < ActiveRecord::Migration t.timestamps <% end -%> end + +<% attributes.select {|attr| attr.reference? }.each do |attribute| -%> + add_index :<%= table_name %>, :<%= attribute.name %>_id +<% end -%> end def down |