diff options
Diffstat (limited to 'activerecord/lib/rails/generators/active_record/model/templates/migration.rb')
-rw-r--r-- | activerecord/lib/rails/generators/active_record/model/templates/migration.rb | 8 |
1 files changed, 4 insertions, 4 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 1f68487304..cd2552d9b8 100644 --- a/activerecord/lib/rails/generators/active_record/model/templates/migration.rb +++ b/activerecord/lib/rails/generators/active_record/model/templates/migration.rb @@ -1,5 +1,5 @@ class <%= migration_class_name %> < ActiveRecord::Migration - def self.up + def change create_table :<%= table_name %> do |t| <% for attribute in attributes -%> t.<%= attribute.type %> :<%= attribute.name %> @@ -8,9 +8,9 @@ class <%= migration_class_name %> < ActiveRecord::Migration t.timestamps <% end -%> end - end - def self.down - drop_table :<%= table_name %> +<% attributes.select {|attr| attr.reference? }.each do |attribute| -%> + add_index :<%= table_name %>, :<%= attribute.name %>_id +<% end -%> end end |