Sha256: 8a3e31757a05aa17c8e3361148f092f36a081765781d3ec40b402831ee38c951

Contents?: true

Size: 1.22 KB

Versions: 29

Compression:

Stored size: 1.22 KB

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 %><%= attribute.inject_options %>
    <%- if attribute.has_index? -%>
    add_index :<%= table_name %>, :<%= attribute.index_name %><%= attribute.inject_index_options %>
    <%- end %>
<%- 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 %><%= attribute.inject_options %><% end %>
    <% if attribute.has_index? && migration_action == 'add' %>
    add_index :<%= table_name %>, :<%= attribute.index_name %><%= attribute.inject_index_options %>
    <% 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 %><%= attribute.inject_options %><% end %>
  <%- end -%>
<%- end -%>
  end
<%- end -%>
end

Version data entries

29 entries across 24 versions & 3 rubygems

Version Path
challah-0.6.2 vendor/bundle/gems/activerecord-3.2.2/lib/rails/generators/active_record/migration/templates/migration.rb
challah-0.6.1 vendor/bundle/gems/activerecord-3.2.1/lib/rails/generators/active_record/migration/templates/migration.rb
challah-0.6.1 vendor/bundle/gems/activerecord-3.2.2/lib/rails/generators/active_record/migration/templates/migration.rb
challah-0.6.0 vendor/bundle/gems/activerecord-3.2.1/lib/rails/generators/active_record/migration/templates/migration.rb
challah-0.6.0 vendor/bundle/gems/activerecord-3.2.2/lib/rails/generators/active_record/migration/templates/migration.rb
challah-0.5.4 vendor/bundle/gems/activerecord-3.2.2/lib/rails/generators/active_record/migration/templates/migration.rb
challah-0.5.4 vendor/bundle/gems/activerecord-3.2.1/lib/rails/generators/active_record/migration/templates/migration.rb
challah-0.5.3 vendor/bundle/gems/activerecord-3.2.1/lib/rails/generators/active_record/migration/templates/migration.rb
challah-0.5.3 vendor/bundle/gems/activerecord-3.2.2/lib/rails/generators/active_record/migration/templates/migration.rb
challah-0.5.2 vendor/bundle/gems/activerecord-3.2.1/lib/rails/generators/active_record/migration/templates/migration.rb
challah-0.5.2 vendor/bundle/gems/activerecord-3.2.2/lib/rails/generators/active_record/migration/templates/migration.rb
challah-0.5.1 vendor/bundle/gems/activerecord-3.2.2/lib/rails/generators/active_record/migration/templates/migration.rb
activerecord-3.2.2 lib/rails/generators/active_record/migration/templates/migration.rb
activerecord-3.2.2.rc1 lib/rails/generators/active_record/migration/templates/migration.rb
challah-0.5.0 vendor/bundle/gems/activerecord-3.2.1/lib/rails/generators/active_record/migration/templates/migration.rb
challah-0.4.1 vendor/bundle/gems/activerecord-3.2.1/lib/rails/generators/active_record/migration/templates/migration.rb
challah-0.4.0 vendor/bundle/gems/activerecord-3.2.1/lib/rails/generators/active_record/migration/templates/migration.rb
challah-0.3.5 vendor/bundle/gems/activerecord-3.2.1/lib/rails/generators/active_record/migration/templates/migration.rb
challah-0.3.4 vendor/bundle/gems/activerecord-3.2.1/lib/rails/generators/active_record/migration/templates/migration.rb
challah-0.3.3 vendor/bundle/gems/activerecord-3.2.1/lib/rails/generators/active_record/migration/templates/migration.rb