Skip to content

Migrations history is not filtered based on enabled migrations namespaces #13183

@djagya

Description

@djagya

Lets say in our app we have a module (for example app/modules/admin) with namespaced migrations and our own namespaced migrations.
In the app config we have this block:

'controllerMap' => [
    'migrate' => [
        'class' => 'yii\console\controllers\MigrateController',
        'migrationNamespaces' => ['app\migrations'],
        'migrationPath' => null, // disable all non-namespaced migrations
    ],
],

And applied migrations ordered by apply_time:

  • app\migrations\M161210195701CreateUserTable
  • app\migrations\M161210195702CreateProfileTable
  • app\modules\admin\migrations\M161210195703CreateAccessTable
  • app\modules\admin\migrations\M161210195704CreatePostTable
  • app\migrations\M161210195705CreateRoleTable
  • app\modules\admin\migrations\M161210195706AddSomeColumn

I expect the yii\console\controllers\MigrateController::getMigrationHistory() method, that's used by migrate/history and migrate/down commands, will filter the applied migrations by the migration namespaces.

For example:
./yii migrate/history (where migrationNamespaces = ['app\migrations'] from the app config) should return only migrations from the app\migrations namespace:

(datetime) app\migrations\M161210195701CreateUserTable
(datetime) app\migrations\M161210195702CreateProfileTable
(datetime) app\migrations\M161210195705CreateRoleTable

Whereas ./yii migrate/history --migrationNamespaces=app\modules\admin\migrations should return only migrations from the module namespace:

(datetime) app\modules\admin\migrations\M161210195703CreateAccessTable
(datetime) app\modules\admin\migrations\M161210195704CreatePostTable
(datetime) app\modules\admin\migrations\M161210195706AddSomeColumn

Isn't that the expected behavior?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions