Sha256: 6fe3ad366fe2c84c4c98e0c3b91ad03cc343b598f28cc582c2752972ce04f9bb

Contents?: true

Size: 827 Bytes

Versions: 57

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

57 entries across 57 versions & 3 rubygems

Version Path
activerecord-3.1.12 lib/rails/generators/active_record/migration/templates/migration.rb
activerecord-3.1.11 lib/rails/generators/active_record/migration/templates/migration.rb
activerecord-3.1.10 lib/rails/generators/active_record/migration/templates/migration.rb
activerecord-3.1.9 lib/rails/generators/active_record/migration/templates/migration.rb
dirty_history-0.7.3 dirty_history/ruby/1.9.1/gems/activerecord-3.1.1/lib/rails/generators/active_record/migration/templates/migration.rb
dirty_history-0.7.2 dirty_history/ruby/1.9.1/gems/activerecord-3.1.1/lib/rails/generators/active_record/migration/templates/migration.rb
dirty_history-0.7.1 dirty_history/ruby/1.9.1/gems/activerecord-3.1.1/lib/rails/generators/active_record/migration/templates/migration.rb
dirty_history-0.7.0 dirty_history/ruby/1.9.1/gems/activerecord-3.1.1/lib/rails/generators/active_record/migration/templates/migration.rb
dirty_history-0.6.7 dirty_history/ruby/1.9.1/gems/activerecord-3.1.1/lib/rails/generators/active_record/migration/templates/migration.rb
dirty_history-0.6.6 dirty_history/ruby/1.9.1/gems/activerecord-3.1.1/lib/rails/generators/active_record/migration/templates/migration.rb
dirty_history-0.6.5 dirty_history/ruby/1.9.1/gems/activerecord-3.1.1/lib/rails/generators/active_record/migration/templates/migration.rb
dirty_history-0.6.4 dirty_history/ruby/1.9.1/gems/activerecord-3.1.1/lib/rails/generators/active_record/migration/templates/migration.rb
activerecord-3.1.8 lib/rails/generators/active_record/migration/templates/migration.rb
dirty_history-0.6.3 dirty_history/ruby/1.9.1/gems/activerecord-3.1.1/lib/rails/generators/active_record/migration/templates/migration.rb
multi-database-migrations-0.0.1.1 lib/generators/multi_migration/templates/migration.rb
activerecord-3.1.7 lib/rails/generators/active_record/migration/templates/migration.rb
dirty_history-0.6.2 dirty_history/ruby/1.9.1/gems/activerecord-3.1.1/lib/rails/generators/active_record/migration/templates/migration.rb
dirty_history-0.6.1 dirty_history/ruby/1.9.1/gems/activerecord-3.1.1/lib/rails/generators/active_record/migration/templates/migration.rb
dirty_history-0.6.0 dirty_history/ruby/1.9.1/gems/activerecord-3.1.1/lib/rails/generators/active_record/migration/templates/migration.rb
activerecord-3.1.6 lib/rails/generators/active_record/migration/templates/migration.rb