Sha256: 51a49de49e52c987ff51794ef88836c92da64628a7b83acb180266d381f5f00f

Contents?: true

Size: 843 Bytes

Versions: 19

Compression:

Stored size: 843 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 %>, 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

19 entries across 19 versions & 1 rubygems

Version Path
mobility-0.5.1 lib/rails/generators/mobility/templates/table_migration.rb
mobility-0.5.0 lib/rails/generators/mobility/templates/table_migration.rb
mobility-0.4.3 lib/rails/generators/mobility/templates/table_migration.rb
mobility-0.4.2 lib/rails/generators/mobility/templates/table_migration.rb
mobility-0.4.1 lib/rails/generators/mobility/templates/table_migration.rb
mobility-0.4.0 lib/rails/generators/mobility/templates/table_migration.rb
mobility-0.3.6 lib/rails/generators/mobility/templates/table_migration.rb
mobility-0.3.5 lib/rails/generators/mobility/templates/table_migration.rb
mobility-0.3.4 lib/rails/generators/mobility/templates/table_migration.rb
mobility-0.3.3 lib/rails/generators/mobility/templates/table_migration.rb
mobility-0.3.2 lib/rails/generators/mobility/templates/table_migration.rb
mobility-0.3.1 lib/rails/generators/mobility/templates/table_migration.rb
mobility-0.3.0 lib/rails/generators/mobility/templates/table_migration.rb
mobility-0.2.3 lib/rails/generators/mobility/templates/table_migration.rb
mobility-0.2.2 lib/rails/generators/mobility/templates/table_migration.rb
mobility-0.2.1 lib/rails/generators/mobility/templates/table_migration.rb
mobility-0.2.0 lib/rails/generators/mobility/templates/table_migration.rb
mobility-0.1.20 lib/rails/generators/mobility/templates/table_migration.rb
mobility-0.1.19 lib/generators/rails/mobility/templates/table_migration.rb