-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
schemadiff: remove table name from auto-generated FK constraint name #14385
schemadiff: remove table name from auto-generated FK constraint name #14385
Conversation
Signed-off-by: Shlomi Noach <[email protected]>
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
@@ -42,6 +42,9 @@ func ExtractConstraintOriginalName(tableName string, constraintName string) stri | |||
if strings.HasPrefix(constraintName, fmt.Sprintf("%s_fk_", tableName)) { | |||
return constraintName[len(tableName)+1:] | |||
} | |||
if strings.HasPrefix(constraintName, fmt.Sprintf("%s_ibfk_", tableName)) { | |||
return constraintName[len(tableName)+1:] | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need the case above this one still? Since that’s not what the automatic names look like?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
… '_ibfk' Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Description
Similarly to #10638, this PR removes the table name from auto-generated foreign key constraint names. The reason is that due to MySQL behavior, when you
RENAME TABLE t TO something_else
, all auto-generated constraints names, including foreign key names, are likewise renamed. In the above example, that means the constraint name length increases by13
characters. With Vitess internal names that easily risks running out of constraint name allowed length (64
characters), which in turn fails theRENAME
.The existing code was already meant to deal with the situation, but by mistake used
fk
, rather thanibfk
, as the indicator for auto-generated names.Related Issue(s)
Checklist
Deployment Notes