<?php

use yii\db\Migration;

class m160812_140415_tax_group_to_category extends Migration
{
    public function up()
    {
        $this->createTable('tax_group_to_category', [
            'tax_group_to_category_id' => $this->primaryKey(),
            'tax_group_id' => $this->integer()->notNull(),
            'category_id' => $this->integer()->notNull(),
        ]);

        $this->addForeignKey('tax_group_fk', 'tax_group_to_category', 'tax_group_id', 'tax_group', 'tax_group_id', 'CASCADE', 'CASCADE');
        $this->addForeignKey('category_fk', 'tax_group_to_category', 'category_id', 'category', 'category_id', 'CASCADE', 'CASCADE');
    }

    public function down()
    {
        $this->dropForeignKey('tax_group_fk', 'tax_group_to_category');
        $this->dropForeignKey('category_fk', 'tax_group_to_category');
        $this->dropTable('tax_group_to_category');
    }
}
