<?php

use yii\db\Schema;
use yii\db\Migration;

class m160217_095148_create_school_lessons_image extends Migration
{
    public function safeUp()
    {
        $tableOptions = null;
        if ($this->db->driverName === 'mysql') 
        {
            $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB';
        }
        
        // Структура таблицы `school_lessons_image`
 
        $this->createTable('school_lessons_image', [
            'id' => Schema::TYPE_PK,
            'filename' => Schema::TYPE_STRING . '(50) NOT NULL',
            'lesson_id' => Schema::TYPE_INTEGER . '(11) NOT NULL', 
        ], $tableOptions);
        
        $this->createIndex('FK_school_lessons_image_lessons', 'school_lessons_image', 'lesson_id');
    }

    public function safeDown()
    {
        $this->dropTable('school_lessons_image');
    }
}
