How To Perform Db Migrate On Second Db

Hi, i have the db connection configure as below:




'db' => [

            'class' => 'yii\db\Connection',

            'dsn' => 'mysql:host=localhost;dbname=csposxe',

            'username' => '****',

            'password' => '****',

            'charset' => 'utf8',

        ],

        'db-archive' => [

            'class' => 'yii\db\Connection',

            'dsn' => 'mysql:host=localhost;dbname=csarchive',

            'username' => '****',

            'password' => '****',

            'charset' => 'utf8',

        ],



As i know when we use $this->createTable() in migration will create table in the default "db" connection. How about if i wan the migration to execute on db-archive?

Thanks in advanced.

yii migrate/up --db=db-archive




    ./yiic migrate --connectionID=db-archive



It was --connectionID in 1.1. In 2.0 it’s --db.

Hi, thanks for the reply. I have a nother question. Let say I have 3 migration file now but only the last in the order is the migration I want to execute on db-archive. So by executing --db=db-archive, the first and the second migration will be execute on db-archive too?

Right, sorry, I did not realize the forum.

:D

You can do yii migrate/up 1 --db=xxx

Hi samdark, if i specify 1 it only execute the 1st migration file, but how if i wan to skip 1 and 2, and only wan to execute the 3rd migrate?

Migrations should be executed sequentially else there’s no sense in these. If you want to totally separate independent migrations you need separate directories and separate DB tables storing info about what was applied.

Ok thank you for the help :)