Skip to content
This repository
9  activerecord/lib/rails/generators/active_record/migration/templates/migration.rb
@@ -12,10 +12,7 @@ def change
12 12
   def up
13 13
 <% attributes.each do |attribute| -%>
14 14
   <%- if migration_action -%>
15  
-    <%= migration_action %>_column :<%= table_name %>, :<%= attribute.name %><% if migration_action == 'add' %>, :<%= attribute.type %><%= attribute.inject_options %><% end %>
16  
-    <%- if attribute.has_index? && migration_action == 'add' -%>
17  
-    add_index :<%= table_name %>, :<%= attribute.index_name %><%= attribute.inject_index_options %>
18  
-    <%- end -%>
  15
+    <%= migration_action %>_column :<%= table_name %>, :<%= attribute.name %>
19 16
   <%- end -%>
20 17
 <%- end -%>
21 18
   end
@@ -23,8 +20,8 @@ def up
23 20
   def down
24 21
 <% attributes.reverse.each do |attribute| -%>
25 22
   <%- if migration_action -%>
26  
-    <%= migration_action == 'add' ? 'remove' : 'add' %>_column :<%= table_name %>, :<%= attribute.name %><% if migration_action == 'remove' %>, :<%= attribute.type %><%= attribute.inject_options %><% end %>
27  
-    <%- if attribute.has_index? && migration_action == 'remove' -%>
  23
+    add_column :<%= table_name %>, :<%= attribute.name %>, :<%= attribute.type %><%= attribute.inject_options %>
  24
+    <%- if attribute.has_index? -%>
28 25
     add_index :<%= table_name %>, :<%= attribute.index_name %><%= attribute.inject_index_options %>
29 26
     <%- end -%>
30 27
   <%- end -%>

0 notes on commit 925f2e9

Please sign in to comment.
Something went wrong with that request. Please try again.