D
D
des1roer2017-06-18 09:17:04
Yii
des1roer, 2017-06-18 09:17:04

Yii2 2db migration?

kind people. made two database connections. when migrating I get
Exception 'yii\base\InvalidConfigException' with message 'The configuration for the "db" component must contain a "class" element.'
although the databases are connected correctly and the site sees them

return [
    'db' => [
        'class' => 'yii\db\Connection',
        'dsn' => 'mysql:host=localhost;dbname=localdb',
        'username' => 'root',
        'password' => '',
        'charset' => 'utf8',
        'tablePrefix' => 'ds_',
    ],
    'db_dev' => [
        'class' => 'yii\db\Connection',
        'dsn' => 'mysql:host=localhost;dbname=dev',
        'username' => 'root',
        'password' => '',
        'charset' => 'utf8',
        'tablePrefix' => 'dev_',
    ]
];;

in config
'db' => $db['db'],
        'db_dev' => $db['db_dev'],

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2017-06-18
@des1roer

Good morning.
The db_dev directory contains migration files for the db_dev database
Or in migration

public function init()
    {
        $this->db = 'db_dev';
        parent::init();
    }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question