<?php

use yii\db\Migration;

class m160426_105524_add_blog_schedule extends Migration
{
    public function up()
    {
        $this->createTable(
            'blog_schedule',
            [
                'id' => $this->primaryKey(),
                'sent' => $this->integer(1)->defaultValue(0),
                'email' => $this->string(255)->notNull(),
                'post_id' => $this->integer(11)->notNull(),
                'date' => $this->date()->notNull()
            ]
        );
        $this->addForeignKey(
            'fk_blog_schedule_post_id',
            'blog_schedule', 'post_id',
            'posts', 'id'
        );
    }

    public function down()
    {
        $this->dropForeignKey(
            'fk_blog_schedule_post_id',
            'blog_schedule'
        );
        $this->dropTable('blog_schedule');
    }
}
