2

I have followed this step by step instruction to create a table in my database using migrate command but I wondered how it is finalized at the last step. after running "yiic migrate" command I get the following message:

Yii Migration Tool v1.0 (based on Yii v1.1.13)

exception 'CDbException' with message 'CDbConnection.connectionString cannot be
empty.' in D:\wamp\www\news\framework\db\CDbConnection.php:369
Stack trace:
#0 D:\wamp\www\news\framework\db\CDbConnection.php(330): CDbConnection->open()
#1 D:\wamp\www\news\framework\db\CDbConnection.php(308): CDbConnection->setActiv
e(true)
#2 D:\wamp\www\news\framework\base\CModule.php(387): CDbConnection->init()
#3 D:\wamp\www\news\framework\cli\commands\MigrateCommand.php(442): CModule->get
Component('db')
#4 D:\wamp\www\news\framework\cli\commands\MigrateCommand.php(451): MigrateComma
nd->getDbConnection()
#5 D:\wamp\www\news\framework\cli\commands\MigrateCommand.php(482): MigrateComma
nd->getMigrationHistory(-1)
#6 D:\wamp\www\news\framework\cli\commands\MigrateCommand.php(84): MigrateComman
d->getNewMigrations()
#7 [internal function]: MigrateCommand->actionUp(Array)
#8 D:\wamp\www\news\framework\console\CConsoleCommand.php(172): ReflectionMethod
->invokeArgs(Object(MigrateCommand), Array)
#9 D:\wamp\www\news\framework\console\CConsoleCommandRunner.php(67): CConsoleCom
mand->run(Array)
#10 D:\wamp\www\news\framework\console\CConsoleApplication.php(91): CConsoleComm
andRunner->run(Array)
#11 D:\wamp\www\news\framework\base\CApplication.php(169): CConsoleApplication->
processRequest()
#12 D:\wamp\www\news\framework\yiic.php(33): CApplication->run()
#13 D:\wamp\www\news\framework\yiic(14): require_once('D:\wamp\www\new...')
#14 {main}

I don't know what command I have to run after it and how to finish up with the migration process!

Does anybody have a solution on this issue? (I am also using windows 7)

Hamid Ghorashi
  • 1,003
  • 3
  • 14
  • 29

2 Answers2

2

Inside config/console.php add database configuration

'components' => array(
  'db'=> array(
    'connectionString' => '',
  'username' => '',
  'password' => '',
  )
)   

with appropriate database details

Neophile
  • 1,519
  • 12
  • 15
  • It worked for me. Be sure to have the same configuration by @neophile in config/console.php. I mean you need to have a db element in the components array in console.php. – ZJ Lyu Dec 11 '13 at 09:41
0

You seem to miss the db configuration block in your config/console.php.

Michael Härtl
  • 8,428
  • 5
  • 35
  • 62
  • 1
    I have already set the database configuration both in main.php and console.php – Hamid Ghorashi Aug 21 '13 at 07:13
  • I have copied framework folder from Yii main folder that I downloaded from the official website and then edited the first line of the code in index.php as follows: $yii=dirname(__FILE__).'/framework/yii.php'; – Hamid Ghorashi Aug 21 '13 at 07:20