for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
use yii\db\Migration;
class m190809_120000_article extends Migration
{
/**
* @return bool|void
*/
public function safeUp()
$this->createTable('{{%articles}}', [
'id' => $this->primaryKey(),
'title' => $this->string()->notNull(),
'content' => $this->text(),
'category_id' => $this->integer()->notNull(),
]);
$this->createTable('{{%article_categories}}', [
'name' => $this->string()->notNull(),
$this->insert('{{%article_categories}}', [
'id' => 1,
'name' => 'Category1'
'id' => 2,
'name' => 'Category2'
$this->insert('{{%articles}}', [
'category_id' => 1,
'title' => 'Article1'
'title' => 'Article2'
}
public function safeDown()
$this->dropTable('{{%articles}}');
$this->dropTable('{{%article_categories}}');