开发者

Is there a way to change the MySQL Database Engine with Doctrine Migrations

does anyone know a way to write a Doctrine migration to change the Table Engine of a MySQL Database from MyISAM to InnoDB? Can this be开发者_JAVA技巧 managed via Migrations or do I have to this the old way via SQL-Statements?


You may want to investigate the 2.0 version of Doctrine Migrations. It would not be compatible with migrations from Doctrine 1.2, but you can use it on any database, without having to use the Doctrine 2 ORM.

Anyway, using this version, it's as simple as:

$this->addSql('ALTER TABLE mytable ENGINE=INNODB');


There is a way to do it via migrations (I'm using doctrine 1.2):

public function up()
{
  $q = Doctrine_Manager::getInstance()->getCurrentConnection();
  $q->execute("ALTER TABLE foo ENGINE = MyISAM");
}


Unfortunately you can only create, rename or delete a table with doctrine migrations.
You will have to do this the old fashioned way :)

Check the Doctrine Documentation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜