Description
Bug Report
Q | A |
---|---|
Version | 3.8.4 |
Summary
I had created a migration via the symfony command doc:mig:diff early in development that created a new table and a new foreign key constraint to an already existing table. Later I must have changed something that influenced the foreign key name generation because if i delete the constraint now and create a new migration, it has a different name.
Old FK name: FK_E19D9AD24A7A78F6
New FK name: FK_E19D9AD2491C2540
Current behaviour
I would expect doctrine to pick up on that change and drop the old foreign key and create a new one but that isn't the case - it just gets ignored. This is due to Schema/Comperator.php:diffForeignKey() not checking for that name change. This function just checks if the foreign key columns, tables or actions changed.
How to reproduce
Rename an existing foreign key constraint and create a table diff.
Expected behaviour
The comperator should notice the foreign change and therefore drop the "orphaned" key and create a new one with the correct name.
Proposed change
Adding the following lines to the diffForeignKey() function will fix the issue:
if (strtolower($key1->getName()) !== strtolower($key2->getName())) { return true; }
Activity