If in the migration classes in the init() method there is no fixed specific base, then by calling the migrate command, you can specify the --db option in which you can point to the connection component to the required base.
For example: yii migrate --db=db2 — apply migrations to the db2 database.
This will not work if a specific database is specified in the init() method. For example:
public function init() { $this->db = 'db3'; parent::init(); }
In your case, as I understand it, you need to start the migration immediately after successful registration. How to start the migration command from the application read here: https://stackoverflow.com/questions/27983169/how-to-handle-yii2-migrations-on-hosts-without-console-access , and then: http: / /www.yiiframework.com/forum/index.php/topic/60000-run-migrate-command-in-a-function-in-yii2/ .
And here's what you need to do ( based on the fact that you have read the links given and what kind of code it is and where you already understand it ):
new \yii\console\Application([ 'id' => 'Command runner', 'basePath' => '@app', 'components' => [ 'db' => ... /* тут нужно будет зарегистрировать компонент подключения к только что созданной базе данных. Зная ее имя, с этим не должно возникнуть трудностей */ ], ]);
Controller'ein theAction, which you are responsible for registering the user . - MasterAlex