Sha256: ceda278040bb8dbd22844e77b55ec9fe2f5254b0cb0fe79b4f3b7687a9174ec3

Contents?: true

Size: 1.14 KB

Versions: 43

Compression:

Stored size: 1.14 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.references :<%=model_table_name.singularize %>, null: false, foreign_key: true, index: false

      t.timestamps null: false
    end

    add_index :<%= table_name %>, :locale, name: :<%= translation_index_name("locale") %>
    add_index :<%= table_name %>, [:<%= foreign_key %>, :locale], name: :<%= translation_index_name(foreign_key, "locale") %>, unique: true

<%- attributes_with_index.each do |attribute| -%>
  add_index :<%= table_name %>, [:<%= attribute.index_name %><%= attribute.inject_index_options %>, :locale], name: :<%= translation_index_name(attribute.index_name, "locale") %>
<%- end -%>
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

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