<?php

use yii\db\Migration;

/**
 * Class m180531_115620_alter_table_question
 */
class m180531_115620_alter_table_question extends Migration
{
    /**
     * {@inheritdoc}
     */
    public function safeUp()
    {
        $this->addColumn('question', 'doctor_id', $this->integer());
        
        $this->addForeignKey('question_doctor_fk',
                            'question',
                            'doctor_id',
                            'doctor',
                            'id',
                            'SET NULL',
                            'CASCADE');
    }

    /**
     * {@inheritdoc}
     */
    public function safeDown()
    {
        $this->dropForeignKey('question_doctor_fk', 'question');
        $this->dropColumn('coctor_id', 'question');
    }

    /*
    // Use up()/down() to run migration code without a transaction.
    public function up()
    {

    }

    public function down()
    {
        echo "m180531_115620_alter_table_question cannot be reverted.\n";

        return false;
    }
    */
}
