File: lib/generators/extension_migration/templates/migration.rb

Code

Code

   1  class <%= class_name.underscore.camelize %> < ActiveRecord::Migration
   2    def self.up<% attributes.each do |attribute| %>
   3      <%= migration_action %>_column :<%= table_name %>, :<%= attribute.name %><% if migration_action == 'add' %>, :<%= attribute.type %><% end -%>
   4    <%- end %>
   5    end
   6 
   7    def self.down<% attributes.reverse.each do |attribute| %>
   8      <%= migration_action == 'add' ? 'remove' : 'add' %>_column :<%= table_name %>, :<%= attribute.name %><% if migration_action == 'remove' %>, :<%= attribute.type %><% end -%>
   9    <%- end %>
  10    end
  11  end