Enum dtatatype in Mygration


I am new in yii 2.0 I am trying to implement the migration and I have a table where one field is enum type and has a default value. but am not getting a way to define this in

$this->createTable(‘example_table’, [

‘id’ => $this->primaryKey(),

‘name’ => $this->string(64)->notNull(),

‘type’ => $this->integer()->notNull()->defaultValue(10),

‘description’ => $this->text(),

‘rule_name’ => $this->string(64),

‘data’ => $this->text(),

‘created_at’ => $this->datetime()->notNull(),

‘updated_at’ => $this->datetime(),


Can any one help me out from this problem…

Thanks In advance

use ‘smallInteger’ for this.

The ENUM data type isn’t standard SQL.


Or you can use tinyint, if you don’t have more then 255 options… (tinyint(3) unsigned)

tinyint isn’t standard sql too.