<?php

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

class m160210_004018_create_table_lessons_lang extends Migration
{
    public function safeUp()
    {
        $tableOptions = null;
        if ($this->db->driverName === 'mysql') 
        {
            $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB';
        }
        
        // Структура таблицы `courses_lang`
 
        $this->createTable('lessons_lang', [
            'id' => Schema::TYPE_PK,
            'lang_id' => Schema::TYPE_INTEGER . '(11) NOT NULL', 
            'lesson_id' => Schema::TYPE_INTEGER . '(11) NOT NULL', 
            'title' => Schema::TYPE_STRING . '(150) NOT NULL',
            'text' => Schema::TYPE_TEXT . ' NOT NULL',
        ], $tableOptions);
        
        $this->createIndex('FK_lessons_lang_languages', 'lessons_lang', 'lang_id');
        $this->createIndex('FK_lessons_lang_lessons', 'lessons_lang', 'lesson_id');
    }

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