AO3-6893 Use rebuild_constraints to modify foreign keys #5066
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.
Issue
https://otwarchive.atlassian.net/browse/AO3-6893
Purpose
@zz9pzza referenced this blog post. Our options:
rebuild_constraints
is safest but slow since it involves copying data from the old to the new table.drop_swap
is fast but risky and not rollback friendly.auto
is not a real third option, it picks between the first two by estimating how long it takes to copy data between the two tables.Since we're using MariaDB, rebuilding constraints as an online operation can be fast (not requiring a full table copy) as long as we disable
foreign_key_checks
:We would need to set:
However, the version of pt-osc we use (3.5.4) has percona/percona-toolkit#483, which set
foreign_key_checks=0
only briefly when running alter table. That means we can simply set:Testing Instructions
Retry the migrations in #5039.