3 class CreateLanguages < ActiveRecord::Migration
5 create_table :languages, innodb_table do |t|
6 t.string :code, :null => false
7 t.string :english_name, :null => false
11 add_primary_key :languages, [:code]
13 YAML.load(File.read(RAILS_ROOT + "/config/languages.yml")).each do |k,v|
14 Language.create do |l|
16 l.english_name = v["english"]
17 l.native_name = v["native"]
21 add_foreign_key :users, [:locale], :languages, [:code]
22 add_foreign_key :diary_entries, [:language], :languages, [:code]
26 raise IrreversibleMigration.new