This is the default code for migration
<?php
use yii\db\Schema;
use yii\db\Migration;
class m150101_185401_create_news_table extends Migration
{
public function up()
{
$this->createTable('news', [
'id' => Schema::TYPE_PK,
'title' => Schema::TYPE_STRING . ' NOT NULL',
'content' => Schema::TYPE_TEXT,
]);
}
public function down()
{
$this->dropTable('news');
}
}
here TYPE_TEXT is a predefined attribute, since I can create my own trait, for example int (11) Not NULL, unsigned unsignedInt, there is a way to create my own traits.
source
share