Sha256: 74e61f0eb2014e42c7e2c281e3a33d77ae35f5967b2fdccf9db05b46d3678365

Contents?: true

Size: 1003 Bytes

Versions: 50

Compression:

Stored size: 1003 Bytes

Contents

class <%= migration_class_name %> < <%= activerecord_migration_class %>
  def change
<% attributes.each do |attribute| -%>
  <%- if attribute.reference? -%>
    add_reference :<%= table_name %>, :<%= attribute.name %><%= attribute.inject_options %>
  <%- elsif attribute.respond_to?(:token?) && attribute.token? -%>
    add_column :<%= table_name %>, :<%= attribute.name %>, :string<%= attribute.inject_options %>
    add_index :<%= table_name %>, [:<%= attribute.index_name %><%= attribute.inject_index_options %>, :locale], name: :<%= translation_index_name(attribute.index_name, "locale") %>, 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 %>, :locale], name: :<%= translation_index_name(attribute.index_name, "locale") %>
    <%- end -%>
  <%- end -%>
<% end -%>
  end
end

Version data entries

50 entries across 50 versions & 1 rubygems

Version Path
mobility-1.3.0.rc3 lib/rails/generators/mobility/templates/table_migration.rb
mobility-1.3.0.rc2 lib/rails/generators/mobility/templates/table_migration.rb
mobility-1.3.0.rc1 lib/rails/generators/mobility/templates/table_migration.rb
mobility-1.2.9 lib/rails/generators/mobility/templates/table_migration.rb
mobility-1.2.8 lib/rails/generators/mobility/templates/table_migration.rb
mobility-1.2.7 lib/rails/generators/mobility/templates/table_migration.rb
mobility-1.2.6 lib/rails/generators/mobility/templates/table_migration.rb
mobility-1.2.5 lib/rails/generators/mobility/templates/table_migration.rb
mobility-1.2.4 lib/rails/generators/mobility/templates/table_migration.rb
mobility-1.2.3 lib/rails/generators/mobility/templates/table_migration.rb
mobility-1.2.2 lib/rails/generators/mobility/templates/table_migration.rb
mobility-1.2.1 lib/rails/generators/mobility/templates/table_migration.rb
mobility-1.2.0 lib/rails/generators/mobility/templates/table_migration.rb
mobility-1.1.3 lib/rails/generators/mobility/templates/table_migration.rb
mobility-1.1.2 lib/rails/generators/mobility/templates/table_migration.rb
mobility-1.1.1 lib/rails/generators/mobility/templates/table_migration.rb
mobility-1.1.0 lib/rails/generators/mobility/templates/table_migration.rb
mobility-1.0.7 lib/rails/generators/mobility/templates/table_migration.rb
mobility-1.0.6 lib/rails/generators/mobility/templates/table_migration.rb
mobility-1.0.5 lib/rails/generators/mobility/templates/table_migration.rb