class CreateCategoryLangs < ActiveRecord::Migration
  def change
    create_table :category_langs do |t|
      t.string :name
      t.string :slug
      t.text :description
      t.integer :image_file_id
      t.references :lang_site, index: true
      t.references :category, index: true

      t.timestamps null: false
    end
    
    Category.all.each do |cat|
      cat.category_langs <<  CategoryLang.new(:name => cat.name, :description => cat.description, :slug => cat.slug, :lang_site_id => 1)
      cat.category_langs <<  CategoryLang.new(:name => cat.name, :slug => cat.slug, :lang_site_id => 2)
      cat.save
    end
    
    
  end
end
