Migrations

parent daf3bac0
<?php
use yii\db\Schema;
use yii\db\Migration;
class m160209_233922_create_table_courses_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('courses_lang', [
'id' => Schema::TYPE_PK,
'lang_id' => Schema::TYPE_INTEGER . '(11) NOT NULL',
'course_id' => Schema::TYPE_INTEGER . '(11) NOT NULL',
'title' => Schema::TYPE_STRING . '(150) NOT NULL',
'description' => Schema::TYPE_TEXT . ' NOT NULL',
'description_for_course' => Schema::TYPE_TEXT . ' NOT NULL',
], $tableOptions);
$this->createIndex('FK_courses_lang_languages', 'courses_lang', 'lang_id');
$this->createIndex('FK_courses_lang_courses', 'courses_lang', 'course_id');
}
public function safeDown()
{
$this->dropTable('courses_lang');
}
}
<?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');
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment