public function safeUp()
{
$tableOptions = null;
if($this->db->driverName === 'mysql'){
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB';
}
$this->createTable('{{%catalog}}',[
'id' => $this->primaryKey(),
'name' => $this->string(50)->notNull(),
'locate' => $this->integer()->notNull(),
'slug' => $this->string(),
'icon' => $this->string(),
'parent_id' => $this->integer()->null(),
'status' => $this->smallInteger()->notNull()->defaultValue(0),
'created_at' => $this->integer(),
'updated_at' => $this->integer()
], $tableOptions);
$this->createIndex('idx-category-parent_id','{{%catalog}}','parent_id');
$this->addForeignKey('fk-category_parent_id', '{{%catalog}}', 'parent_id', '{{%catalog}}', 'id', 'SET NULL', 'RESTRICT');
}
public function safeDown()
{
$this->dropTable('{{%catalog}}');
}
php yii
? Простой просмотр консольных команд...