aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/generators/active_record/migration/templates/migration.rb
blob: 2851f7cb4290ceb15d4baad0a7609a124070ae18 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
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 %>
  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 %>
  end
end