diff options
author | Marc-Andre Lafortune <github@marc-andre.ca> | 2012-12-18 19:43:33 -0500 |
---|---|---|
committer | Marc-Andre Lafortune <github@marc-andre.ca> | 2012-12-21 13:54:52 -0500 |
commit | aedcd683684d08eaf30623a4b48ce31a31426372 (patch) | |
tree | df58f858501989698f9cb0e26108f1da9d201473 /activerecord/lib/rails | |
parent | 7204d3c63e0c412c638b885fb552ec50e7c1520a (diff) | |
download | rails-aedcd683684d08eaf30623a4b48ce31a31426372.tar.gz rails-aedcd683684d08eaf30623a4b48ce31a31426372.tar.bz2 rails-aedcd683684d08eaf30623a4b48ce31a31426372.zip |
Migration generators use `change` even for destructive methods [#8267]
Diffstat (limited to 'activerecord/lib/rails')
-rw-r--r-- | activerecord/lib/rails/generators/active_record/migration/templates/migration.rb | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/activerecord/lib/rails/generators/active_record/migration/templates/migration.rb b/activerecord/lib/rails/generators/active_record/migration/templates/migration.rb index d5c07aecd3..ae9c74fd05 100644 --- a/activerecord/lib/rails/generators/active_record/migration/templates/migration.rb +++ b/activerecord/lib/rails/generators/active_record/migration/templates/migration.rb @@ -21,28 +21,16 @@ class <%= migration_class_name %> < ActiveRecord::Migration end end <%- else -%> - def up + def change <% attributes.each do |attribute| -%> <%- if migration_action -%> <%- if attribute.reference? -%> - remove_reference :<%= table_name %>, :<%= attribute.name %><%= ', polymorphic: true' if attribute.polymorphic? %> + remove_reference :<%= table_name %>, :<%= attribute.name %><%= attribute.inject_options %> <%- else -%> - remove_column :<%= table_name %>, :<%= attribute.name %> - <%- end -%> -<%- end -%> -<%- end -%> - end - - def down -<% attributes.reverse.each do |attribute| -%> -<%- if migration_action -%> - <%- if attribute.reference? -%> - add_reference :<%= table_name %>, :<%= attribute.name %><%= attribute.inject_options %> - <%- else -%> - add_column :<%= table_name %>, :<%= attribute.name %>, :<%= attribute.type %><%= attribute.inject_options %> <%- if attribute.has_index? -%> - add_index :<%= table_name %>, :<%= attribute.index_name %><%= attribute.inject_index_options %> + remove_index :<%= table_name %>, :<%= attribute.index_name %><%= attribute.inject_index_options %> <%- end -%> + remove_column :<%= table_name %>, :<%= attribute.name %>, :<%= attribute.type %><%= attribute.inject_options %> <%- end -%> <%- end -%> <%- end -%> |