Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when creating log table with migration #6206

Closed
nikbas opened this issue Nov 24, 2014 · 2 comments
Closed

Error when creating log table with migration #6206

nikbas opened this issue Nov 24, 2014 · 2 comments
Assignees

Comments

@nikbas
Copy link
Contributor

nikbas commented Nov 24, 2014

When I try to apply the

log/migrations/m141106_185632_log_init.php

it throws an exception as if there is no DbTarget configured.
I have it configured in components log config:

'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                 'db' => [
                    'class' => 'yii\log\DbTarget',
                    'levels' => ['error', 'warning'],
             ],            
    ],
],

I've tried code from getDbTargets() function, which throws the exception, and it works fine outside of the console and returns the DbTarget object as expected. Somehow this exception is only thrown in console.

Yii Migration Tool (based on Yii v2.0.1-dev)

Exception 'yii\base\InvalidConfigException' with message 'You should configure "log" component to use one or more database targets before executing this migration.'

Stack trace:
#0 /var/www/project/vendor/yiisoft/yii2/log/migrations/m141106_185632_log_init.php(54): m141106_185632_log_init->getDbTargets()
#1 /var/www/project/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(489): m141106_185632_log_init->up()
#2 /var/www/project/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(126): yii\console\controllers\BaseMigrateController->migrateUp('m141106_185632_...')
#3 [internal function]: yii\console\controllers\BaseMigrateController->actionUp(0)
#4 /var/www/project/vendor/yiisoft/yii2/base/InlineAction.php(55): call_user_func_array(Array, Array)
#5 /var/www/project/vendor/yiisoft/yii2/base/Controller.php(151): yii\base\InlineAction->runWithParams(Array)
#6 /var/www/project/vendor/yiisoft/yii2/console/Controller.php(91): yii\base\Controller->runAction('', Array)
#7 /var/www/project/vendor/yiisoft/yii2/base/Module.php(455): yii\console\Controller->runAction('', Array)
#8 /var/www/project/vendor/yiisoft/yii2/console/Application.php(161): yii\base\Module->runAction('migrate', Array)
#9 /var/www/project/vendor/yiisoft/yii2/console/Application.php(137): yii\console\Application->runAction('migrate', Array)
#10 /var/www/project/vendor/yiisoft/yii2/base/Application.php(375): yii\console\Application->handleRequest(Object(yii\console\Request))
#11 /var/www/project/yii(23): yii\base\Application->run()
#12 {main}

It's on ubuntu 14.04.
@samdark any thoughts on why this is happening

@samdark
Copy link
Member

samdark commented Nov 24, 2014

There are two configs: console and web in basic app. In advanced app there are more. Are you sure DB target is configured for console?

@nikbas
Copy link
Contributor Author

nikbas commented Nov 24, 2014

My mistake, sorry. I edited wrong console.php.

Thanks.

@samdark samdark closed this as completed Nov 24, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants