Skip to content

No namespace defined in migration m141106_185632_log_init.php #13142

@vinpel

Description

@vinpel

What steps will reproduce the problem?`

I want to integrate the yii2 log database component, in advanced app :
File : console\config\main.php
what doesn't work :

  'controllerMap'       => [
    'migrate' => [
      'class' => 'yii\console\controllers\MigrateController',
      'migrationNamespaces' => [
        "yii\log\migrations", //yii2 log2database
      ],
      //  'migrationPath' =>        "@yii/log/migrations"
    ],
  ],

the relevant file is :

yiisoft\yii2\log\migrations\m141106_185632_log_init.php

What is the expected result?

Creating migration history table "migration"...Done.
Total 1 new migrations to be applied:
        yii\log\migrations\m141106_185632_log_init
Apply the above migrations? (yes|no) [no]:yes
*** applying m141106_185632_log_init
    > create table {{%log}} ... done (time: 0.052s)
    > create index idx_log_level on {{%log}} (level) ... done (time: 0.015s)
    > create index idx_log_category on {{%log}} (category) ... done (time: 0.023s)
*** applied m141106_185632_log_init (time: 0.101s)

What do you get instead?

Apply the above migrations? (yes|no) [no]:yes
*** applying yii\log\migrations\m141106_185632_log_init
PHP Fatal error:  Cannot redeclare class m141106_185632_log_init in /data/htdocs/vendor/yiisoft/yii2/log/migrations/m141106_185632_log_init.php on line 86
PHP Compile Error 'yii\base\ErrorException' with message 'Cannot redeclare class m141106_185632_log_init'

in /data/htdocs/vendor/yiisoft/yii2/log/migrations/m141106_185632_log_init.php:86

Additional info

to make it work :

  'controllerMap'       => [
    'migrate' => [
      'class' => 'yii\console\controllers\MigrateController',
      'migrationNamespaces' => [
//        "yii\log\migrations", //yii2 log2database
      ],
        'migrationPath' =>        "@yii/log/migrations"
    ],
  ],

in this case only 1 migrationPath allowed so ... not pretty good

Or add the new namespace migration function

Q A
Yii version 2.0.10
PHP version PHP 5.6.27 (cli)
Operating system Alpine 3.3.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions