<?php
    
    use yii\db\Migration;
    
    /**
     * Handles the creation for table `product_variant_lang`.
     */
    class m160929_175821_create_product_variant_lang_table extends Migration
    {
        
        /**
         * @inheritdoc
         */
        public function up()
        {
            $this->createTable('product_variant_lang', [
                'product_variant_id' => $this->integer()
                                             ->notNull(),
                'language_id'        => $this->integer()
                                             ->notNull(),
                'name'               => $this->string()
                                             ->notNull(),
            ]);
            $this->createIndex('product_variant_lang_product_variant_language_key', 'product_variant_lang', [
                'product_variant_id',
                'language_id',
            ], true);
            
            $this->addForeignKey('product_variant_fk', 'product_variant_lang', 'product_variant_id', 'product_variant', 'product_variant_id', 'CASCADE', 'CASCADE');
            $this->addForeignKey('language_fk', 'product_variant_lang', 'language_id', 'language', 'language_id', 'RESTRICT', 'CASCADE');
        }
        
        /**
         * @inheritdoc
         */
        public function down()
        {
            $this->dropTable('product_variant_lang');
        }
    }
