Class: CreateTranslations

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
lib/generators/acts_as_simple_translatable/templates/migration.rb

Instance Method Summary collapse

Instance Method Details

#changeObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/generators/acts_as_simple_translatable/templates/migration.rb', line 2

def change
  # create translations table if it doesn't exist
  create_table :translations do |t|
    t.integer :translatable_id, required: true
    t.string :translatable_type, required: true
    t.string :translatable_field, required: true
    t.string :locale, length: 5, required: true
    t.text :content
    t.timestamps
  end

  # add index
  add_index :translations, [:translatable_id, :translatable_type, :locale], name: 'record_translations_index'
end