<?php

use yii\db\Migration;

class m160428_141739_add_tamplates_column_to_posts_table extends Migration
{
    public function up()
    {
        $this->addColumn(
            'posts',
            'template_id',
            $this->integer(11)->defaultValue(NULL)
        );
        $this->addForeignKey(
            'fk_posts_tamplate_id',
            'posts', 'template_id',
            'message_template', 'id'
        );
    }

    public function down()
    {
        $this->dropForeignKey(
            'fk_posts_tamplate_id',
            'posts'
        );
        $this->dropColumn(
            'posts',
            'template_id'
        );
    }
}
