Yii2. Freestanding Migration. Why cling to an unspecified migration?

common/config/main.php
return [
 'vendorPath' => dirname(dirname(__DIR__)) . '/vendor',
 'components' => [
 'cache' => [
 'class' => 'yii\caching\FileCache',
],
],

 'bootstrap' => [
'user-manager',
],

 'modules' => [
 'user-manager' => [
 'class' => 'common\modules\UserManager\Module',
 'plugins' => ['profile'],
],
],

 'controllerMap' => [
 'migrate-app' => [
 'class' => 'yii\console\controllers\MigrateController',
 //'migrationNamespaces' => ["],
 'migrationTable' => 'migration',
],
],
];


common/modules/UserManager/Module.php
class Module extends \yii\base\Module
{
 public $plugins = [];

/**
 * @inheritdoc
*/
 public $controllerNamespace = 'common\modules\UserManager\controllers';

/**
 * @inheritdoc
*/
 public function init()
{
parent::init();

 $plugins = [];
 if(isset($this->plugins) && !empty($this->plugins)){
 $this->plugins = array_flip($this->plugins);

if(isset($this->plugins['profile'])){
 $plugins['profile'] = [
 'class' => 'common\modules\UserManager\modules\Profile\Module'
];
}
}
 $this->modules = $plugins;
 if(\Yii::$app instanceof \yii\console\Application){
 $migName[] = 'common\modules\UserManager\migrations';
if(isset($this->plugins['profile'])){
 $migName[] = 'common\modules\UserManager\modules\Profile\migrations';
}

 \Yii::$app->controllerMap['migrate-user-manager'] = [
 'class' => 'yii\console\controllers\MigrateController',
 'migrationNamespaces' => $migName,
 'migrationTable' => 'migration_user_manager',
];
}
}
}


When the command in the console:
./yii migrate-user-manager
Yii offers to perform all migration and even those that are not specified for this command.
Yii Migration Tool (based on Yii v2.0.11.2)

Total 3 new migrations to be applied:
m130524_201442_init
common\modules\UserManager\migrations\m170424_124532_user_manager_init
common\modules\UserManager\modules\Profile\migrations\m170502_154236_user_manager_profile

Apply the above migrations? (yes|no) [no]:n

Why is this happening and how to fix it?
June 26th 19 at 16:32
2 answers
June 26th 19 at 16:34
Oh, something You wise. Read more here how to organize freestanding migration
Using this article I do so like it is described. The only difference I describe in the file common\config\main.php. Although described here is the config I also tried the result is the same.
return [
 'vendorPath' => dirname(dirname(__DIR__)) . '/vendor',
 'components' => [
 'cache' => [
 'class' => 'yii\caching\FileCache',
],
],

 'bootstrap' => [
'user-manager',
],

 'modules' => [
 'user-manager' => [
 'class' => 'common\modules\UserManager\Module',
 'plugins' => ['profile'],
],
],

 'controllerMap' => [
 'migrate-app' => [
 'class' => 'yii\console\controllers\MigrateController',
 //'migrationNamespaces' => ["],
 'migrationTable' => 'migration',
],
 'migrate-module' => [
 'class' => 'yii\console\controllers\MigrateController',
 'migrationNamespaces' => [
'common\modules\UserManager\migrations',
'common\modules\UserManager\modules\Profile\migrations'
],
 'migrationTable' => 'migration_user_manager',
],
],
];
- rose.Lindgren commented on June 26th 19 at 16:37
: how caused with this configuration? - bryana.Renn commented on June 26th 19 at 16:40
./yii migrate -- app passes without error. There is only 1 migration - create table User.
./yii migrate-module is also without error. But this team is hitting on a migration to create a table User. But this should not be. This command should produce 2 migrations creating tables. 1 module and 1 with a submodule. - rose.Lindgren commented on June 26th 19 at 16:43
June 26th 19 at 16:36
Got into the source code and found that in the class BaseMigrateController migrationNamespace converted to paths to the folders with the migration files and merge into one array with migrationPath(which defaults to '@app/migrations'). And accordingly cling all migrations from that folder in a heap with the migrations namespace. And if you have a different table for storing migration module and applications, the migration from the default folder are not executed. Either they forgot to add the test to not use migrationPath if specified migrationNamspace, or it was made intentionally for some reason. I will not continue to deal with...
Treatment add to the config command migrationPath => null.
It turns out that's how it looks:
'controllerMap' => [
 'migrate-module' => [
 'class' => 'yii\console\controllers\MigrateController',
 'migrationNamespaces' => [
'namespace\from\module',
'namespace\another'
],
 'migrationTable' => 'migration_module',
 'migrationPath' => null,
],
 ],

Find more questions by tags YiiMigration of data