Sha256: cba9fc1e974ec6864ef1c7efaed1a37c8907a7667dd7455ac83754862b85f37e

Contents?: true

Size: 1.08 KB

Versions: 19

Compression:

Stored size: 1.08 KB

Contents

class <%= migration_class_name %> < <%= activerecord_migration_class %>
  def change
    create_table :<%= table_name %><%= primary_key_type if respond_to?(:primary_key_type) %> do |t|

      # Translated attribute(s)
<% attributes.each do |attribute| -%>
<% if attribute.respond_to?(:token?) && attribute.token? -%>
      t.string :<%= attribute.name %><%= attribute.inject_options %>
<% else -%>
      t.<%= attribute.type %> :<%= attribute.name %><%= attribute.inject_options %>
<% end -%>
<% end -%>

      t.string  :locale, null: false
      t.integer :<%= foreign_key %>, null: false

      t.timestamps null: false
    end

    add_index :<%= table_name %>, :<%= foreign_key %>, name: :<%= translation_index_name %>
    add_index :<%= table_name %>, :locale, name: :<%= translation_locale_index_name %>
    add_index :<%= table_name %>, [:<%= foreign_key %>, :locale], name: :<%= translation_unique_index_name %>, unique: true

<%- attributes_with_index.each do |attribute| -%>
    add_index :<%= table_name %>, :<%= attribute.index_name %><%= attribute.inject_index_options %>
<%- 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_translations.rb
mobility-0.5.0 lib/rails/generators/mobility/templates/table_translations.rb
mobility-0.4.3 lib/rails/generators/mobility/templates/table_translations.rb
mobility-0.4.2 lib/rails/generators/mobility/templates/table_translations.rb
mobility-0.4.1 lib/rails/generators/mobility/templates/table_translations.rb
mobility-0.4.0 lib/rails/generators/mobility/templates/table_translations.rb
mobility-0.3.6 lib/rails/generators/mobility/templates/table_translations.rb
mobility-0.3.5 lib/rails/generators/mobility/templates/table_translations.rb
mobility-0.3.4 lib/rails/generators/mobility/templates/table_translations.rb
mobility-0.3.3 lib/rails/generators/mobility/templates/table_translations.rb
mobility-0.3.2 lib/rails/generators/mobility/templates/table_translations.rb
mobility-0.3.1 lib/rails/generators/mobility/templates/table_translations.rb
mobility-0.3.0 lib/rails/generators/mobility/templates/table_translations.rb
mobility-0.2.3 lib/rails/generators/mobility/templates/table_translations.rb
mobility-0.2.2 lib/rails/generators/mobility/templates/table_translations.rb
mobility-0.2.1 lib/rails/generators/mobility/templates/table_translations.rb
mobility-0.2.0 lib/rails/generators/mobility/templates/table_translations.rb
mobility-0.1.20 lib/rails/generators/mobility/templates/table_translations.rb
mobility-0.1.19 lib/generators/rails/mobility/templates/table_translations.rb