NativeDDL: analyzing added&removed unique keys #8495
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
First, we're unofficially adopting the term "NativeDDL" for OnlineDDL/VReplication based migrations.
In this PR we add an analysis: does the migration introduce any new unique key constraints? Does it remove any unique key constraints?
The analysis isn't necessarily for a specific key. It is about the overall state of the table before/after migration. Is there a set of columns that was previous unconstrained and now forms a unqieu constraints? Regardless of how we got there, whether by
ADD KEY
orREMOVE KEY
.The information is persisted in
schema_migrations
table in these columns:both
int unsigned not null default 0
, and indicate the number of added constraints and number of removed constraints, respectively.Why
This is fundamental to automating revertible migrations. Not all migrations are revertible. If you add a new constraint, and start using it, then reverting back to old table means you are now able to add what you consider as duplicates. And if you revert-the-revert (roll forward), then that may fail altogether.
So in this PR we first collect the information. Later on we can have educated logic based on that information.
Nothing right now actually uses the information gathered in this PR (other than in
endtoend
tests).Change is tested in unit&endtoend tests.
Related Issue(s)
#6926
Checklist