trejder
trejder

Reputation: 17495

Permanently customize migration table in yiic migration

Is there anyway to permanently force yiic inside protected folder of my application, to always (no matter, what) use customized table name for migrations?

The only way, I found is "standard" way of yiic migrate --migrationTable=migrations. But this is very bad approach. Any (accidental or intentional) miss / forget in adding this extra parameter and entire migration will crack, as yiic will create new, empty tbl_migration table, instead of use proper migrations one.

Upvotes: 0

Views: 49

Answers (1)

Konstantin
Konstantin

Reputation: 566

class MyMigrateCommand extends MigrateCommand {

    public $migrationTable='migrations';

}

Also you can update yiic.php file:

...
$app = Yii::createConsoleApplication($config);

$statConfig = require_once(dirname(__FILE__).'/config/console.php');
$app->configure($statConfig);

$app->commandRunner->commands = $statConfig['commandMap'];
...

and add into config:

...
'commandMap' => array(
        'class'=>'system.cli.commands.MigrateCommand',
        'migrationTable'=>'stat_tbl_migration',
),
...

Upvotes: 1

Related Questions