<?php

use yii\db\Migration;

class m160412_092830_add_analytics_school_lesson_files_table extends Migration
{
    // Use safeUp/safeDown to run migration code within a transaction
    public function safeUp()
    {
        $this->createTable(
            'analytics_school_lesson_file',
            [
                'id' => $this->primaryKey(),
                'lesson_id' => $this->integer(11)->notNull(),
                'title' => $this->string(255)->notNull(),
                'file' => $this->text()->notNull()
            ]
        );
        $this->addForeignKey(
            'fk_analytics_school_lesson_file_lesson_id',
            'analytics_school_lesson_file', 'lesson_id',
            'analytics_school_lesson', 'id'
        );
    }

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