Class: CreateActiveTranslationTables

Inherits:
Object
  • Object
show all
Defined in:
lib/generators/active_translation/templates/create_active_translation_tables.rb

Instance Method Summary collapse

Instance Method Details

#changeObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/generators/active_translation/templates/create_active_translation_tables.rb', line 2

def change
  create_table :active_translation_translations do |t|
    t.references :translatable, polymorphic: true, null: false
    t.string :locale, null: false
    t.text :translated_attributes
    t.string :source_checksum
    t.timestamps
  end

  add_index :active_translation_translations, [ :translatable_type, :translatable_id, :locale ],
    unique: true, name: "index_translations_on_translatable_and_locale"

  create_table :active_translation_cache do |t|
    t.string :locale, null: false
    t.string :checksum
    t.text :translated_text
  end

  add_index :active_translation_cache, [ :checksum, :locale ], unique: true
end