<?php

use yii\db\Migration;
use yii\db\Schema;

class m160127_133404_trigger_condition extends Migration
{
//    public function up()
//    {
//
//    }
//
//    public function down()
//    {
//        echo "m160127_133404_trigger_condition cannot be reverted.\n";
//
//        return false;
//    }

    // Use safeUp/safeDown to run migration code within a transaction
    public function safeUp()
    {
        $this->createTable(
            'trigger_condition',
            [
                'id' => Schema::TYPE_PK,
                'group_number' => Schema::TYPE_INTEGER.' NOT NULL',
                'trigger_id' => Schema::TYPE_INTEGER.' NOT NULL'
            ]
        );
        $this->addForeignKey(
            'fk_condition_trigger_id',
            'trigger_condition', 'trigger_id',
            'trigger_trigger', 'id'
        );
    }

    public function safeDown()
    {
        $this->dropForeignKey(
            'fk_condition_trigger_id',
            'trigger_condition'
        );
        $this->dropTable('trigger_condition');
    }

}
