运行 Yii-user 扩展的迁移时出现“迁移目录不存在”错误


"migration directory does not exist" error when running Yii-user extension's migrations

我有一个由Composer安装的Yii框架,webapp public_html文件夹中,以及供应商文件夹中的所有库:

webroot
|
|_public_html
|
|_vendor
  |
  |_fierwebdesign
    |
    |_yii-user
      |
      |_migrations

我在console.php中的配置是:

'modules'=>array(
  'user'=>array(
     'hash' => 'md5',
      'sendActivationMail' => true,
      'loginNotActiv' => false,
      'activeAfterRegister' => false,
      'autoLogin' => true,
      'registrationUrl' => array('/user/registration'),
      'recoveryUrl' => array('/user/recovery'),
      'loginUrl' => array('/user/login'),
      'returnUrl' => array('/user/profile'),
      'returnLogoutUrl' => array('/user/login'),
    ),
),

当我尝试运行 Yii-user 扩展的迁移时,我收到错误:

yiic.php migrate --migrationPath=vendor.fierwebdesign.yii-user.migrations
Error: The migration directory does not exist: vendor.fierwebdesign.yii-user.migrations

我做错了什么?

您需要

在配置中声明vendor别名。如果您的主机.php在public_html/config/中比声明是:

Yii::setPathOfAlias('vendor', dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' .
               DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '_vendor');

也许这会有所帮助:

console.php配置文件的 components 数组中编写类似的东西;

    'commandMap' => array(
        'migrate' => array(
            'class' => 'system.cli.commands.MigrateCommand',
            'migrationPath' => 'application.modules.user.migrations',
//            'migrationTable' => 'tbl_migration',
            'connectionID' => 'db',
//            'templateFile' => 'application.migrations.template',
        ),

然后给出命令:php migrate

此外,在这种情况下,app/modules/user/migartion文件夹必须存在,并且必须包含迁移文件

最好的猜测是migrationPath实际上指的是文件系统路径,而不是像你正在使用的别名