Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix foreign key name change detection #6413

Merged

Conversation

achterin
Copy link
Contributor

Q A
Type bug
Fixed issues #6390

Summary

This changes how the schema comparator treats foreign key name changes.
The index renaming had the same behavior in the past, expecting a index name change to result in an empty table diff. This was changed some time ago but foreign key changes were still not picked up by the comparator. This pr will change that.
While at it, I've also changed the names of both tests to reflect the changes.

@achterin achterin force-pushed the bugfix/foreign_key_name_change_detection branch 2 times, most recently from 6603566 to e51eb77 Compare May 29, 2024 10:07
@greg0ire
Copy link
Member

The index renaming had the same behavior in the past, expecting a index name change to result in an empty table diff. This was changed some time ago but foreign key changes were still not picked up by the comparator.

Please add links showing that.

@achterin
Copy link
Contributor Author

The index renaming had the same behavior in the past, expecting a index name change to result in an empty table diff. This was changed some time ago but foreign key changes were still not picked up by the comparator.

Please add links showing that.

Sure, no problem. This changeset introduced the index-rename support and changed the corresponding test. As you can see, before this patch the test expected an empty table-diff - same as for the fk-name test below.

a996bea#diff-1e412c2c0134199408e114ba49a15f2019f3ccbac5472c3815f59c815f810e45

@greg0ire
Copy link
Member

Since this is a bugfix, and it affects 3.x, you should retarget this PR on 3.8.x (and rebase on that).

@achterin
Copy link
Contributor Author

Okay, I thought it would be the other way around, so fix it first in the default branch and then backport it. Will do.

@achterin achterin force-pushed the bugfix/foreign_key_name_change_detection branch from e51eb77 to 25a2d03 Compare May 31, 2024 22:03
@achterin achterin changed the base branch from 4.0.x to 3.8.x May 31, 2024 22:04
@achterin
Copy link
Contributor Author

@greg0ire sadly i was unable to adapt my exact changes to the 3.8.x branch, thats why i did reduce the test down to just checking if one foreign key was added and one removed. i also used the deprecated diffTable function to be in line with the other tests.
i guess this should be reworked in the way i had initially committed it when merging this into the newer version branches.

let me know what you think. thanks!

@greg0ire
Copy link
Member

greg0ire commented Jun 1, 2024

I think you should open another PR after we merge this up to adapt the test.

@greg0ire greg0ire closed this Jun 1, 2024
@greg0ire greg0ire reopened this Jun 1, 2024
As index renaming support was introduced a while back do the same for
foreign key name changes.

Signed-off-by: Christoph Krapp <[email protected]>
Both tests did expect a name change to result in an empty table diff in
the past. When index renaming support was introduced the name of the
test was not changed to reflect the new expectation.

Signed-off-by: Christoph Krapp <[email protected]>
@achterin achterin force-pushed the bugfix/foreign_key_name_change_detection branch from 25a2d03 to 422e459 Compare June 1, 2024 08:19
@greg0ire greg0ire added this to the 3.8.5 milestone Jun 1, 2024
@greg0ire greg0ire merged commit 080aab5 into doctrine:3.8.x Jun 1, 2024
92 checks passed
@greg0ire
Copy link
Member

greg0ire commented Jun 1, 2024

Thanks @achterin !

vitek-rostislav added a commit to shopsys/shopsys that referenced this pull request Jun 12, 2024
vitek-rostislav added a commit to shopsys/shopsys that referenced this pull request Jun 12, 2024
ShopsysBot pushed a commit to shopsys/framework that referenced this pull request Jun 12, 2024
vitek-rostislav added a commit to shopsys/shopsys that referenced this pull request Jun 14, 2024
- this is the version where indexes detection has changed
- see doctrine/dbal#6413
vitek-rostislav added a commit to shopsys/shopsys that referenced this pull request Jun 14, 2024
- this is the version where indexes detection has changed
- see doctrine/dbal#6413
ShopsysBot pushed a commit to shopsys/framework that referenced this pull request Jun 14, 2024
- this is the version where indexes detection has changed
- see doctrine/dbal#6413
ShopsysBot pushed a commit to shopsys/category-feed-luigis-box that referenced this pull request Jun 14, 2024
- this is the version where indexes detection has changed
- see doctrine/dbal#6413
ShopsysBot pushed a commit to shopsys/product-feed-zbozi that referenced this pull request Jun 14, 2024
- this is the version where indexes detection has changed
- see doctrine/dbal#6413
ShopsysBot pushed a commit to shopsys/product-feed-google that referenced this pull request Jun 14, 2024
- this is the version where indexes detection has changed
- see doctrine/dbal#6413
ShopsysBot pushed a commit to shopsys/product-feed-heureka that referenced this pull request Jun 14, 2024
- this is the version where indexes detection has changed
- see doctrine/dbal#6413
ShopsysBot pushed a commit to shopsys/product-feed-luigis-box that referenced this pull request Jun 14, 2024
- this is the version where indexes detection has changed
- see doctrine/dbal#6413
ShopsysBot pushed a commit to shopsys/article-feed-luigis-box that referenced this pull request Jun 14, 2024
- this is the version where indexes detection has changed
- see doctrine/dbal#6413
ShopsysBot pushed a commit to shopsys/brand-feed-luigis-box that referenced this pull request Jun 14, 2024
- this is the version where indexes detection has changed
- see doctrine/dbal#6413
ShopsysBot pushed a commit to shopsys/migrations that referenced this pull request Jun 14, 2024
- this is the version where indexes detection has changed
- see doctrine/dbal#6413
greg0ire pushed a commit that referenced this pull request Jun 18, 2024
…e_change_detection"

This reverts commit 080aab5, reversing
changes made to a5d2baf.
greg0ire added a commit that referenced this pull request Jun 18, 2024
Revert "Merge pull request #6413 from achterin/bugfix/foreign_key_name_change_detection"
derrabus added a commit to derrabus/dbal that referenced this pull request Jun 18, 2024
* 3.8.x:
  PHPStan 1.11.5 (doctrine#6446)
  Revert "Merge pull request doctrine#6413 from achterin/bugfix/foreign_key_name_change_detection"
  CI: Update MariaDB versions (doctrine#6426)
  CI MariaDB: add 11.4, remove 11.0 (doctrine#6432)
  Fix typo in the portability documentation (doctrine#6430)
derrabus added a commit to derrabus/dbal that referenced this pull request Jun 18, 2024
* 3.8.x:
  Move schema split for SQLite CREATE INDEX only (doctrine#6352)
  PHPStan 1.11.5 (doctrine#6446)
  Revert "Merge pull request doctrine#6413 from achterin/bugfix/foreign_key_name_change_detection"
  CI: Update MariaDB versions (doctrine#6426)
  CI MariaDB: add 11.4, remove 11.0 (doctrine#6432)
  Fix typo in the portability documentation (doctrine#6430)
derrabus added a commit to derrabus/dbal that referenced this pull request Jun 18, 2024
* 3.8.x:
  Move schema split for SQLite CREATE INDEX only (doctrine#6352)
  PHPStan 1.11.5 (doctrine#6446)
  Revert "Merge pull request doctrine#6413 from achterin/bugfix/foreign_key_name_change_detection"
derrabus added a commit to derrabus/dbal that referenced this pull request Jun 19, 2024
* 4.0.x:
  PHPUnit 10.5.21 (doctrine#6447)
  Move schema split for SQLite CREATE INDEX only (doctrine#6352)
  PHPStan 1.11.5 (doctrine#6446)
  Revert "Merge pull request doctrine#6413 from achterin/bugfix/foreign_key_name_change_detection"
derrabus added a commit to derrabus/dbal that referenced this pull request Jun 19, 2024
* 4.1.x: (25 commits)
  Simplify signature of fetchTableOptionsByTable
  Add MariaDb1010Platform for fetchTableOptionsByTable
  PHPUnit 10.5.21 (doctrine#6447)
  Move schema split for SQLite CREATE INDEX only (doctrine#6352)
  PHPStan 1.11.5 (doctrine#6446)
  Default to distinct union queries (doctrine#6439)
  Revert "Merge pull request doctrine#6413 from achterin/bugfix/foreign_key_name_change_detection"
  Add `QueryBuilder` support for `UNION` clause (doctrine#6369)
  CI: Update MariaDB versions (doctrine#6426)
  CI MariaDB: add 11.4, remove 11.0 (doctrine#6432)
  Display warnings when running PHPUnit in CI (doctrine#6431)
  Fix typo in the portability documentation (doctrine#6430)
  Fix MariaDB fetching of default table character-set (doctrine#6361) (doctrine#6425)
  Fix the portability documentation (doctrine#6429)
  Update tests/Platforms/AbstractPlatformTestCase.php
  Update tests/Platforms/AbstractPlatformTestCase.php
  add test
  Fix: Skip type comparison if disableTypeComments is true
  Remove redundant variable (doctrine#6326)
  Fix test names to reflect their actual purpose
  ...
@uncaught
Copy link

uncaught commented Sep 5, 2024

@greg0ire @achterin sorry to bother you, but this fix is critical for our production environment and it seems to have not made it to 4.1 at the moment. Where did this end up in?

@dmaicher you reverted the fix on June 17th (https://github.com/doctrine/dbal/commits/4.1.x/src/Schema/Comparator.php), but afterwards the merge of 3.8 didn't re-add it!? I'm confused.


I'm facing different production systems that cannot migrate because they appear to have accumulated different FK names over some time, so an FK drop in a migration fails horribly.

@derrabus
Copy link
Member

derrabus commented Sep 5, 2024

If the bug resurfaced on 4.1, please submit a new PR against the 4.1 branch.

@uncaught
Copy link

uncaught commented Sep 5, 2024

If the bug resurfaced on 4.1, please submit a new PR against the 4.1 branch.

I'm sorry, it was reverted on purpose, a bit hard to track down.

@derrabus
Copy link
Member

derrabus commented Sep 5, 2024

Okay. Do you want to open a new issue then, explaining the problem that you have?

@uncaught
Copy link

uncaught commented Sep 5, 2024

Okay. Do you want to open a new issue then, explaining the problem that you have?

Yes, I just did: #6518

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants