Sha256: 15d926e63ea83f73bf78af4a1c854a5a092f2c397d3e5fc62ccf3d3b48731ce3

Contents?: true

Size: 827 Bytes

Versions: 7

Compression:

Stored size: 827 Bytes

Contents

class <%= migration_class_name %> < ActiveRecord::Migration
<%- if migration_action == 'add' -%>
  def change
<% attributes.each do |attribute| -%>
    add_column :<%= table_name %>, :<%= attribute.name %>, :<%= attribute.type %>
<%- end -%>
  end
<%- else -%>
  def up
<% attributes.each do |attribute| -%>
  <%- if migration_action -%>
    <%= migration_action %>_column :<%= table_name %>, :<%= attribute.name %><% if migration_action == 'add' %>, :<%= attribute.type %><% end %>
  <%- end -%>
<%- end -%>
  end

  def down
<% attributes.reverse.each do |attribute| -%>
  <%- if migration_action -%>
    <%= migration_action == 'add' ? 'remove' : 'add' %>_column :<%= table_name %>, :<%= attribute.name %><% if migration_action == 'remove' %>, :<%= attribute.type %><% end %>
  <%- end -%>
<%- end -%>
  end
<%- end -%>
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
multi-database-9000-0.4.0 lib/generators/templates/migration.rb
multi-database-9000-0.3.2 lib/generators/templates/migration.rb
multi-database-9000-0.3.1 lib/generators/templates/migration.rb
multi-database-9000-0.3.0 lib/generators/templates/migration.rb
multi-database-9000-0.2.2 lib/generators/templates/migration.rb
multi-database-9000-0.2.1 lib/generators/templates/migration.rb
multi-database-9000-0.2.0 lib/generators/templates/migration.rb