<?php

use yii\db\Migration;

class m160324_144228_add_template_column_to_co_content extends Migration
{
    public function up()
    {
        $this->addColumn(
            'co_content',
            'template_id',
            $this->integer(11)->defaultValue(null)
        );
        $this->createIndex(
            'tempalte',
            'co_content',
            'template_id'
        );
        $this->addForeignKey(
            'fk_co_content_template',
            'co_content', 'template_id',
            'message_template', 'id'
        );
    }

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