mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
DDC-3924: doctrine:schema:update does not recognize that a FK index name has changed #4802
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @doctrinebot on GitHub (Sep 30, 2015).
Originally assigned to: @deeky666 on GitHub.
Jira issue originally created by user senaria:
Reproduce:
Actual:
Expected:
@doctrinebot commented on GitHub (Sep 30, 2015):
Comment created by yakobeyak:
This is not just with foreign keys but all index types. it appears it does not recocnise that the name is different. This cause issues when trying to prepare migrations etc.
@yakobe commented on GitHub (Jan 15, 2016):
@beberlei Could you perhaps have a look at this too see if this is actually a bug in your eyes, or maybe we missed something? Thanks
@deeky666 commented on GitHub (Jan 15, 2016):
@yakobe this sound more like a comparator issue in DBAL. Not sure this is ORM related. Can you please provide a concrete reproducable test case? Also which ORM/DBAL versions are you on? Thanks!
@senaria commented on GitHub (Jan 26, 2016):
@deeky666 I created a project for reproducing this error. It has a simple relation between 2 entities. One index and one foreign key has been manipulated to be wrong.
In brief, its how I said above; changing a name of FK won't be recognized from the doctrine:schema:update command. See this screenshot. As you can see, the renamed IDX is recognized but not the renamed FK.
Reproduce:
@Ocramius commented on GitHub (Jan 26, 2016):
@senaria what @deeky666 needs in order to reproduce the bug is a test that is working in isolation against the schema tool (see for example
a4d84e0cd8/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.phpfor one test doing that).@deeky666 commented on GitHub (Jan 27, 2016):
@senaria reading this I think we'll have to clarify some things first. What exactly is this issue about? The headline says it's about FK index name changes. FKs and indexes are distinct database objects and can be named differently. So according to your investigation, index renaming works as expected. FK renaming is currently unsupported by Doctrine. Actually this is related to DBAL and not ORM. DBAL's schema comparator does not take into account the name when comparing two FKs for differences. So if I understood everything correctly, then is not a bug but a feature request (should go into DBAL issue tracker though).
@yakobe commented on GitHub (Apr 13, 2016):
Just to keep the thread i will continue here. We can create an issue in DBAL if this discussion is going anywhere...
It seems that foreign key name changes are ignored. There is a test in DBAL (https://github.com/doctrine/dbal/blob/master/tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php#L628):
The simplest solution for our problem would be to add an extra check in https://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/Schema/Comparator.php#L389:
Is there a reason for this? Or can this be changed?
@rodnaph commented on GitHub (Dec 7, 2016):
I ran into this issue where I'd altered the schema (which updated some index names) in a branch, then coming back to master the schema tool did not recognise them as needing to be updated (just my busted development setup, but showed how the schema change tool ignored the different key names)
Trying the suggested addition of the key name check worked for me as a fix.
(No opinion on if this is a bug in anything, just reporting experience)