Keeps droping and recreating the same index #128

Closed
mikeSimonson opened this Issue Sep 3, 2013 · 7 comments

Comments

Projects
None yet
4 participants
Member

mikeSimonson commented Sep 3, 2013

Hi,

I odn't know if the problem is in doctrine migration or the dbal but anytime I do a migration diff, the last 2 lines are to drop and recreate those foreign keys (in the up and down methods).

Any idea of the source of the problem ?

$this->addSql("ALTER TABLE ordersdomains DROP FOREIGN KEY FK_D4D861CF8D9F6D38");
$this->addSql("ALTER TABLE ordersdomains ADD CONSTRAINT FK_D4D861CF8D9F6D38 FOREIGN KEY (order_id) REFERENCES `order` (id) ON DELETE CASCADE");
Member

stof commented Sep 3, 2013

what is your database platform ? It is an important information when having to debug such schema comparison issues.

I'm pretty sure the issue comes from DBAL though as the logic to compare the schema is in there. To confirm it, run the doctrine:schema:update --dump-sql command and see if it also contains these queries.

Member

mikeSimonson commented Sep 3, 2013

mysql Ver 14.14 Distrib 5.5.32, for debian-linux-gnu (x86_64) using readline 6.2

And it apparently comes from the DBAL.

Owner

beberlei commented Sep 3, 2013

It seems to be confused by the onDelete cascade foreign key option. Are you
using that in a FK?

On Tue, Sep 3, 2013 at 3:03 PM, mikeSimonson notifications@github.comwrote:

mysql Ver 14.14 Distrib 5.5.32, for debian-linux-gnu (x86_64) using
readline 6.2

And it apparently comes from the DBAL.


Reply to this email directly or view it on GitHubhttps://github.com/doctrine/migrations/issues/128#issuecomment-23710603
.

Member

mikeSimonson commented Sep 3, 2013

The code that trigger the problem is here under.

/**
     * @ORM\ManyToMany(targetEntity="Domain", cascade={"all"})
     * @ORM\JoinTable(name="ordersdomains")
     * @Assert\NotNull()
     **/
    private $domains;
Member

stof commented Sep 3, 2013

Well, cascade={"all"} is a ORM level cascading, not a DB level one. So it is logical that it tries to edit the constraint if it has ON DELETE CASCADE in it, to remove it. What is not logical is that it adds it again in the updated constraint.

Member

deeky666 commented Dec 28, 2013

@mikeSimonson This could be related to your foreign table name order which is a reserved keyword. Did you quote the table name in your mapping for that entity explicitly? This could explain the issue as prior to this commit the comparison of quoted vs unquoted foreign table names could lead to unecessary schema changes.

Member

mikeSimonson commented Dec 30, 2013

Yes it's quoted explicitly.
That commit probably fix it but I have no idea how to test it properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment