Yii2:是否可以更改迁移的默认名称 table?

Yii2: Is it possible to change the default name for the migration table?

默认情况下,Yii 将迁移命名为 table migration 但可以更改此默认值吗?最好也不必在每个迁移文件中指定它...

您可以为此使用 DI 容器。

将以下内容添加到您的 config/console。php

\Yii::$container->set('yii\console\controllers\MigrateController', [
   'migrationTable' => '{{%table_name}}'
]);

在console/config/main.php中你可以在controllerMap中添加你喜欢的表名例如:

  return [
      'id' => 'app-console',
      'basePath' => dirname(__DIR__),
      'bootstrap' => ['log'],
      'controllerNamespace' => 'console\controllers',
      ......
      'controllerMap' => [
          'migrate' => [
              'class' => 'yii\console\controllers\MigrateController',
              'migrationTable' => 'your_migration_table',
          ],
      ],
      .....     
      'components' => [

来自 yii2 指南 http://www.yiiframework.com/doc-2.0/guide-db-migrations.html#customizing-migrations