<?php

use yii\db\Migration;

/**
 * Handles the creation for table `category_lang`.
 */
class m160928_133403_create_category_lang_table extends Migration
{
    /**
     * @inheritdoc
     */
    public function up()
    {
        $this->createTable('category_lang', [
            'category_id'      => $this->integer()
                                       ->notNull(),
            'language_id'      => $this->integer()
                                       ->notNull(),
            'name'            => $this->string()
                                       ->notNull(),
            'meta_title'       => $this->string(),
            'meta_robots'    => $this->string(),
            'meta_desc' => $this->string(),
            'seo_text'         => $this->text(),
            'h1'               => $this->string(),
        ]);
        $this->createIndex('category_lang_category_language_key', 'category_lang', [
            'category_id',
            'language_id',
        ], true);
    
        $this->addForeignKey('category_fk', 'category_lang', 'category_id', 'category', 'category_id', 'CASCADE', 'CASCADE');
        $this->addForeignKey('language_fk', 'category_lang', 'language_id', 'language', 'language_id', 'RESTRICT', 'CASCADE');
    }

    /**
     * @inheritdoc
     */
    public function down()
    {
        $this->dropTable('category_lang');
    }
}
