trouble with multiple db connection strings

I am not having any success running yiic migrate when specifying a non-default connectionID.

I have checked that the migration will run on the desired db by changing the connection string for the default connectionID, db.

I have checked what happens if I specify a connectionID that wasn’t defined (I get a sensible message: Error: CMigrationCommand.connectionID ‘testdb’ is invalid. Please make sure it refers to the ID of a CDbConnection application component.)

I’ve dropped all (two) of the tables in the database in question so that I’m sure the problem isn’t stemming from previous migrations

But, when I specify a defined, non-default connection ID I get the following error message.


 ./yiic migrate --connectionID=testerdb


Yii Migration Tool v1.0 (based on Yii v1.1.<img src='http://www.yiiframework.com/forum/public/style_emoticons/default/cool.gif' class='bbc_emoticon' alt='8)' />


exception 'CException' with message 'Object configuration must be an array containing a "class" element.' in /Users/hjw/php/frameworks/yii-1.1.8.r3324/framework/YiiBase.php:198

Stack trace:

#0 /Users/hjw/php/frameworks/yii-1.1.8.r3324/framework/base/CModule.php(371): YiiBase::createComponent(Array)

#1 /Users/hjw/php/frameworks/yii-1.1.8.r3324/framework/cli/commands/MigrateCommand.php(415): CModule->getComponent('testerdb')

#2 /Users/hjw/php/frameworks/yii-1.1.8.r3324/framework/cli/commands/MigrateCommand.php(423): MigrateCommand->getDbConnection()

#3 /Users/hjw/php/frameworks/yii-1.1.8.r3324/framework/cli/commands/MigrateCommand.php(448): MigrateCommand->getMigrationHistory(-1)

#4 /Users/hjw/php/frameworks/yii-1.1.8.r3324/framework/cli/commands/MigrateCommand.php(75): MigrateCommand->getNewMigrations()

#5 [internal function]: MigrateCommand->actionUp(Array)

#6 /Users/hjw/php/frameworks/yii-1.1.8.r3324/framework/console/CConsoleCommand.php(135): ReflectionMethod->invokeArgs(Object(MigrateCommand), Array)

#7 /Users/hjw/php/frameworks/yii-1.1.8.r3324/framework/console/CConsoleCommandRunner.php(63): CConsoleCommand->run(Array)

#8 /Users/hjw/php/frameworks/yii-1.1.8.r3324/framework/console/CConsoleApplication.php(88): CConsoleCommandRunner->run(Array)

#9 /Users/hjw/php/frameworks/yii-1.1.8.r3324/framework/base/CApplication.php(158): CConsoleApplication->processRequest()

#10 /Users/hjw/php/frameworks/yii-1.1.8.r3324/framework/yiic.php(33): CApplication->run()

#11 /Users/hjw/Projects/yiiBook/trackstar/protected/yiic.php(7): require_once('/Users/hjw/php/...')

#12 /Users/hjw/Projects/yiiBook/trackstar/protected/yiic(4): require_once('/Users/hjw/Proj...')



I’m using the latest version of yii and PHP 5.3.6

What am I missing?

Add classname to the configuration of "testerdb" component:




'testerdb' => array(

  'class' => 'CDbConnection',

  'connectionString' => '...',

  //...

)



Beautiful. That did the trick. How do we get this info put into the docs?

It’s implicated by defining a config for a component not among these predefined components.

/Tommy

I just had the same question/problem today. So thanks for the question & replies guys.

Of course, it’s funny that the error message told me what the problem was, I just assumed it was non-sense (oops).

Still gotta love this framework!