<?php

use yii\db\Migration;

class m160410_110118_add_analytics_school_lessons_table extends Migration
{
    // Use safeUp/safeDown to run migration code within a transaction
    public function safeUp()
    {
        $this->createTable(
            'analytics_school_lessons',
            [
                'id' => $this->primaryKey(),
                'course_id' => $this->integer(11)->notNull(),
                'name' => $this->string(255)->notNull(),
                'video_link' => $this->text()->defaultValue(null),
                'content' => $this->text()->notNull()
            ]
        );
        $this->addForeignKey(
            'fk_analytics_school_course',
            'analytics_school_lessons', 'course_id',
            'analytics_school_course', 'id'
        );
    }

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

}
