开发者

Doctrine/Symfony generated migrations out of order

I'm not sure if this is a bug, but it sure seems like one to me.

When I generate migrations using generate-migrations-diff involving tables that have foreign keys in Symfony, the migrations that result seem to be out of order.

For instance, assuming I have a foreign key in table A to table B, and I delete table B and the referencing field in Table A, the first migration drops Table B and the column in Table A whereas the second migration then drops the foreign key constraint in Table A. The first migration does not work as the field in Table A with the foreign key constraint cannot be dropped, nor can Table B be dropped because of the foreign key constraint.

What should happen is that the foreign key constraint should be dropped first, and then the table and fields should be dropped.

I'm using mysql 5.1.37 as my DBMS.

Here's some of the generated code:

class Version94 extends Doctrine_Migration_Base
{
    public function up()
    {
   开发者_如何学C     $this->dropTable('B');
        $this->removeColumn('A', 'b_id');
    }
.
.
.


class Version95 extends Doctrine_Migration_Base
{
    public function up()
    {
        $this->dropForeignKey('A', 'a_b_id_b_id');
    }


It's almost certainly a bug. In my experience, doctrine:generate-migrations-diff is very unreliable and will generate incorrect migrations for more complex changes.

You can report the issue here.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜