mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fix problem with migrations template that can cause bogus code to be created
Signed-off-by: José Valim <jose.valim@gmail.com>
This commit is contained in:
parent
f9abbf9a4d
commit
4515947845
1 changed files with 8 additions and 4 deletions
|
@ -1,11 +1,15 @@
|
|||
class <%= migration_class_name %> < ActiveRecord::Migration
|
||||
def self.up<% attributes.each do |attribute| %>
|
||||
<%= migration_action %>_column :<%= table_name %>, :<%= attribute.name %><% if migration_action == 'add' %>, :<%= attribute.type %><% end -%>
|
||||
<%- end %>
|
||||
<%- if migration_action -%>
|
||||
<%= migration_action %>_column :<%= table_name %>, :<%= attribute.name %><% if migration_action == 'add' %>, :<%= attribute.type %><% end %>
|
||||
<%- end -%>
|
||||
<%- end -%>
|
||||
end
|
||||
|
||||
def self.down<% attributes.reverse.each do |attribute| %>
|
||||
<%= migration_action == 'add' ? 'remove' : 'add' %>_column :<%= table_name %>, :<%= attribute.name %><% if migration_action == 'remove' %>, :<%= attribute.type %><% end -%>
|
||||
<%- end %>
|
||||
<%- if migration_action -%>
|
||||
<%= migration_action == 'add' ? 'remove' : 'add' %>_column :<%= table_name %>, :<%= attribute.name %><% if migration_action == 'remove' %>, :<%= attribute.type %><% end %>
|
||||
<%- end -%>
|
||||
<%- end -%>
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue