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: auto migrate tries to delete non-existent unique constraint #7135

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

dashrews78
Copy link

@dashrews78 dashrews78 commented Aug 1, 2024

  • Do only one thing
  • Non breaking API changes
  • Tested

What did this pull request do?

This change simply updates the migrator to make sure the unique constraint actually exists prior to deleting this. (Note: We cannot use IF EXISTS because mysql alter table syntax does not support that.)

The reason for this is based on issue #7100 . With the PR #6640 the naming for unique constraints was changed. Previously the migrator was creating unique indexes with a naming prefix of idx_. When #6640 went it, the name changed to be uni_. But if your previous upgrade created the constraint with a name of idx_ the migrator would see you had a constraint and try to delete it. But it was using the updated naming pattern in this statement. So that would result in a command like ALTER TABLE "compliance_integrations" DROP CONSTRAINT "uni_compliance_integrations_clusterid". Since the name of the constraint is idx_compliance_integrations_clusterid the call to DROP CONSTRAINT fails. The point of this change is to simply make it a no-op if the constraint doesn't exist. That will prevent failure. The old constraint may linger in these cases but that is not the scope of this change. The scope of this change is to have a migrator that does not cause unnecessary failures for users.

User Case Description

@varfrog
Copy link

varfrog commented Aug 9, 2024

Thanks for the fix. Hopefully, it ends up in a tag!
A related issue also: #6888

@rayshihUI
Copy link

This PR will help. please do more progress.

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

Successfully merging this pull request may close these issues.

3 participants