You can execute raw SQL inside Migrations, since yii\db\Migration class has an execute($sql, $params = []) method, like
<?php
use yii\db\Migration;
/**
* Handles the creation of table `{{%users}}`.
*/
class m220914_163215_create_users_table extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->execute("
CREATE TABLE `users` (
`user_id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(255) NOT NULL,
`updated_on` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`created_on` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`user_id`),
UNIQUE KEY `username` (`username`),
UNIQUE KEY `user_id` (`user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=5705 DEFAULT CHARSET=latin1;
");
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropTable('{{%users}}');
}
}
Then just run php yii migrate and your table must be created.