<?php
    
    use yii\db\Migration;
    
    /**
     * Handles the creation for table `product_spec_lang`.
     */
    class m160929_155222_create_product_spec_lang_table extends Migration
    {
        
        /**
         * @inheritdoc
         */
        public function up()
        {
            $this->createTable('product_spec_lang', [
                'product_spec_id' => $this->integer()
                                          ->notNull(),
                'language_id'     => $this->integer()
                                          ->notNull(),
                'tech_spec_text'  => $this->text(),
                'instruction'     => $this->text(),
            ]);
            $this->createIndex('product_spec_lang_product_spec_language_key', 'product_spec_lang', [
                'product_spec_id',
                'language_id',
            ], true);
            
            $this->addForeignKey('product_spec_fk', 'product_spec_lang', 'product_spec_id', 'product_spec', 'product_spec_id', 'CASCADE', 'CASCADE');
            $this->addForeignKey('language_fk', 'product_spec_lang', 'language_id', 'language', 'language_id', 'RESTRICT', 'CASCADE');
        }
        
        /**
         * @inheritdoc
         */
        public function down()
        {
            $this->dropTable('product_spec_lang');
        }
    }
