Migrate table prefix

Migrate generates the migration table with Yii’ default prefix ‘tbl_’, not the one I set in the config/console.

it only creates the table with its default name which is tbl_migration, you can configure ‘migrationTable’ property of MigrateCommand to have the table named like you want it.

I know that, CeBe.

It’s only a suggestion: generate the migration table with the prefix defined in config/console.php.

But I think that I had put the in the wrong place. Sorry

This has been discussed in a google code issue, but I couldn’t find it anymore.

When default migration table name has the syntax to accept table prefix with {{ and }} it would not work on databases that have table prefix disabled.

Ok, tx!

Is this going to be fixed in Yii 2 ?

Seriously, what’s the problem?

If a prefix is set, migration should use it.

The old topic in the old issue tracker is here: https://code.google.com/p/yii/issues/detail?id=3001

I just ran into this again…ended up with two migration tables, and had to back one out, then apply changes again and drop unused table. It seems a bit silly that it would use a default prefix of "tbl_" when there is a user-defined prefix already.

Is there at least a simple way to define migrationTable in config so that I don’t have to specify it on the command line every time?

What I’m doing to work around this is one line of code in my migrations:

class m130226_185845_initial_tables extends CDbMigration


	public function up()


        if(! isset(Yii::app()->getDb()->tablePrefix)) { Yii::app()->getDb()->tablePrefix = ''; };

        $this->createTable('{{tablename}}', array( ......

For each up/down function.

Yii should do something like that out of the box, IMO.

I agree…it should. Are you doing anything to change the table where migrations are stored (tbl_migration)? It seems to me that it should be ‘prefix_migration’ as well…

I am not. That would change a core component.

But the extra line of code in each function of the migration will make sure that the tables are created properly, respecting the table prefix (if any) set by the user.

I see no reason why migrations in Yii couldn’t perform the same check and set operation. It seems unnecessary to make use explicitly set the table prefix for the migration table, if you ask me. :)

Yes, you can set this in config/console.php like so (look under heading ‘Configure Command Globally’)

return array(