<?php
    
    use yii\db\Migration;
    
    /**
     * Handles the creation for table `tax_group_lang`.
     */
    class m160930_145734_create_tax_group_lang_table extends Migration
    {
        
        /**
         * @inheritdoc
         */
        public function up()
        {
            $this->createTable('tax_group_lang', [
                'tax_group_id' => $this->integer()
                                       ->notNull(),
                'language_id'  => $this->integer()
                                       ->notNull(),
                'name'         => $this->string()
                                       ->notNull(),
                'description'  => $this->text(),
            ]);
            $this->createIndex('tax_group_lang_tax_group_language_key', 'tax_group_lang', [
                'tax_group_id',
                'language_id',
            ], true);
            
            $this->addForeignKey('tax_group_fk', 'tax_group_lang', 'tax_group_id', 'tax_group', 'tax_group_id', 'CASCADE', 'CASCADE');
            $this->addForeignKey('language_fk', 'tax_group_lang', 'language_id', 'language', 'language_id', 'RESTRICT', 'CASCADE');
        }
        
        /**
         * @inheritdoc
         */
        public function down()
        {
            $this->dropTable('tax_group_lang');
        }
    }
