Sha256: 520dc1a943bff2e2f14cd14d253bca4177972b4f21b54479c28c52ee89b59d37

Contents?: true

Size: 845 Bytes

Versions: 8

Compression:

Stored size: 845 Bytes

Contents

class <%= migration_class_name %> < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
  def change
<% attributes.each do |attribute| -%>
  <%- if attribute.reference? -%>
    add_reference :<%= table_name %>, :<%= attribute.name %><%= attribute.inject_options %>
  <%- elsif attribute.token? -%>
    add_column :<%= table_name %>, :<%= attribute.name %>, :string<%= attribute.inject_options %>
    add_index :<%= table_name %>, :<%= attribute.index_name %><%= attribute.inject_index_options %>, unique: true
  <%- else -%>
    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 -%>
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
mobility-0.1.18 lib/generators/rails/mobility/templates/table_migration.rb
mobility-0.1.17 lib/generators/rails/mobility/templates/table_migration.rb
mobility-0.1.16 lib/generators/rails/mobility/templates/table_migration.rb
mobility-0.1.15 lib/generators/rails/mobility/templates/table_migration.rb
mobility-0.1.14 lib/generators/rails/mobility/templates/table_migration.rb
mobility-0.1.13 lib/generators/rails/mobility/templates/table_migration.rb
mobility-0.1.12 lib/generators/rails/mobility/templates/table_migration.rb
mobility-0.1.11 lib/generators/rails/mobility/templates/table_migration.rb