m160930_145734_create_tax_group_lang_table.php 1.7 KB
<?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(),
                    'title'        => $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',
                'id',
                'CASCADE',
                'CASCADE'
            );
            $this->addForeignKey(
                'language_fk',
                'tax_group_lang',
                'language_id',
                'language',
                'id',
                'RESTRICT',
                'CASCADE'
            );
        }
        
        /**
         * @inheritdoc
         */
        public function down()
        {
            $this->dropTable('tax_group_lang');
        }
    }