<?php

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

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

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