Skip to content
koen handekyn edited this page Jun 27, 2018 · 2 revisions

Somewhat cleaner migration for rails 5.2 with an index. Don't forget to generate your model or create your migration from the below

rails g model Translation locale:string key:string value:text interpolations:text is_proc:boolean

and add the index

add_index :translations, [:locale, :key]
class CreateTranslations < ActiveRecord::Migration[5.2]
  def change
    create_table :translations do |t|
        t.string :locale
        t.string :key
        t.text   :value
        t.text   :interpolations
        t.boolean :is_proc, :default => false
        t.timestamps
    end
    add_index :translations, [:locale, :key]
  end
end
Clone this wiki locally