Use active record in migration with not default database

I have multiple database connection in settings and want to migrate all databeses with same migration.

I use --db propery for this.

yii migrate --db=db1

yii migrate --db=db2

When i use migration’s class commands everything is ok, but i have an error when i try to use active record:


public function up()

    {

        $test = new ColorTag();

        $test->name = "test";

        $test->color = "ffffff";

        $test->save();

    }



How i can use active record in migration in my situation?

You can redefine ‘db’ in separate config file and call migrate with it:

yii migrate --appconfig=path/to/config.php

From guide: http://www.yiiframework.com/doc-2.0/guide-tutorial-console.html