Repository navigation
fix(migrations): finish the adhoc dispatch migration on MySQL 8.4 and after a failed run - #429
Merged
Merged
Conversation
MySQL does not roll back DDL. The v0.8.0 production deploy failed at order_configs, after order_offers, driver_ratings and the orders columns had been created, so a re-run would fail on "table already exists". Each table and column is now created only if missing, and down() drops only what exists.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## release/v0.7.1 #429 +/- ##
==================================================
Coverage 100.00% 100.00%
Complexity 14702 14702
==================================================
Files 676 676
Lines 51313 51313
==================================================
Hits 51313 51313
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This was referenced Nov 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes the v0.8.0 production deploy, which failed in this migration with
SQLSTATE[HY000]: 1553 Cannot drop index '<unknown key name>': needed in a foreign key constraintonalter table order_configs add policies json null.Cause
Production runs MySQL 8.4.8, which turns on
restrict_fk_on_non_standard_keyby default.order_configs.uuidhas an ordinary, non-unique index, and four foreign keys point at it: fromorders,service_rates, and storefront'sstoresandnetworks, which are in the storefront database. With the setting on, MySQL rejects anyALTERoforder_configs, even adding a nullable column. CI's MySQL 8.0 has no such setting, which is why this passed there.Changes
restrict_fk_on_non_standard_keyoff for this session, and the previous value is restored afterwards, even if a step fails. Where the variable doesn't exist (MySQL before 8.4, MariaDB, SQLite), nothing changes.order_offers,driver_ratingsand the threeorderscolumns behind. Each table and column is now created only if it's missing, anddown()drops only what exists. Definitions are unchanged.Testing
I built production's shape for each run:
order_configs.uuidwith a plain index, child foreign keys fromordersandservice_rates, one from a second database, and the partial state the deploy left. Then I ranup(),up()again,down()andup():ALTERONafterwardsNot run: the full fleetops suite, which CI runs.
Follow-up
Any other table whose foreign keys point at a non-unique key will hit the same error the next time a migration alters it on MySQL 8.4. The lasting fix is to make those referenced
uuidcolumns unique.