You are viewing revision #4 of this wiki article.
This is the latest version of this article.
You may want to see the changes made in this revision.
To accomplish the task of changing Migration table's name, by default tbl_migration, you need to add the following in your ./protected/config/console.php.
// Command Map
'commandMap'=>array(
'migrate'=>array(
'class'=>'system.cli.commands.MigrateCommand',
'migrationPath'=>'application.migrations',
'migrationTable'=>'{{migration_history}}',
'connectionID'=>'db',
'templateFile'=>'application.migrations.template',
),
),
The {{ }} makes Yii to use the prefix defined in the 'db' component defined in the same file. This piece of code must be contained by the first array, do not put it under 'components' array.
'components'=>array(
'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=directar',
'emulatePrepare' => true,
'username' => 'root',
'password' => '010101',
'charset' => 'utf8',
'tablePrefix' => 'directar_'
),
....
),
For those who just want to change the table name...
This is great information, but I just wanted to share that if you're looking to just change the name of the Migration Table, all you really need is the following:
'commandMap' => array( 'migrate' => array( 'class' => 'system.cli.commands.MigrateCommand', 'migrationTable' => 'YiiMigrate' ) )
This also assumes that you're using CMap::mergeArray() to merge console.php with something like main.php, which should contain your DB definitions. This is how we're set up so we don't have to duplicate the DB settings in multiple files.
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.