Fix MySQL downgrade from 3.3.0 on deadline_alert.interval JSON conversion#68337
Open
vatsrahul1001 wants to merge 1 commit into
Open
Fix MySQL downgrade from 3.3.0 on deadline_alert.interval JSON conversion#68337vatsrahul1001 wants to merge 1 commit into
vatsrahul1001 wants to merge 1 commit into
Conversation
Contributor
Author
3f9e467 to
8aec6f8
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a MySQL-specific failure in migration 0117’s downgrade path by ensuring the downgrade UPDATE writes valid JSON values while the column is still typed JSON, deferring numeric casting until the subsequent column retype.
Changes:
- Refactors the MySQL downgrade value-conversion SQL into a helper (
_mysql_downgrade_interval_value_sql) that keeps unwrapped values as JSON numbers. - Updates the offline/manual MySQL downgrade instructions to avoid casting JSON-extracted values to non-JSON types during the
UPDATE. - Adds a MySQL regression test that reproduces the failure mode and verifies successful downgrade conversion back to
FLOAT.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| airflow-core/src/airflow/migrations/versions/0117_3_3_0_change_deadline_interval_to_json.py | Fixes MySQL downgrade SQL to avoid invalid JSON writes; updates offline instructions; factors SQL into a helper. |
| airflow-core/tests/unit/migrations/test_0117_deadline_interval_json_migration.py | Adds a regression test ensuring the MySQL downgrade conversion succeeds and round-trips to FLOAT. |
…sion The 3.3.0 migration 0117 (8812eb67b63c) converts deadline_alert.interval to JSON on upgrade and back to FLOAT on downgrade. On MySQL the downgrade unwrapped the value with CAST(... AS DOUBLE) inside an UPDATE that runs while the column is still typed JSON. Writing a non-JSON DOUBLE into a JSON column makes MySQL reject the whole statement with ER_INVALID_JSON_TEXT (3140), so `airflow db downgrade` fails for any deployment that has at least one deadline_alert row. Keep the unwrapped value as a JSON number in the UPDATE and let the subsequent column retype to FLOAT perform the cast, mirroring how the PostgreSQL branch defers the cast to its ALTER ... USING clause. The offline-mode MySQL instructions had the same defect and are corrected too. Adds a MySQL-backend regression test that seeds rows and runs the migration's conversion SQL; the existing migration stairway missed this because it runs against an empty schema (zero rows updated never trips MySQL's per-row JSON validation).
8aec6f8 to
d911e93
Compare
SameerMesiah97
approved these changes
Jun 10, 2026
SameerMesiah97
left a comment
Contributor
There was a problem hiding this comment.
Looks good. Thanks for fixing it.
Contributor
|
All good with me if you want this to merge. |
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.
Migration
0117(8812eb67b63c) convertsdeadline_alert.intervalfromFLOATtoJSONon upgrade and back on downgrade. On MySQL the downgrade unwrapped the value withCAST(... AS DOUBLE)inside anUPDATEthat runs while the column is still typedJSON. Writing a non-JSONDOUBLEinto aJSONcolumn makes MySQL reject the whole statement:So
airflow db downgradefails on MySQL for any deployment with at least onedeadline_alertrow.The fix keeps the unwrapped value as a JSON number in the
UPDATEand lets the subsequent column retype toFLOATperform the cast — mirroring how the PostgreSQL branch defers the cast to itsALTER ... USINGclause. The offline-mode MySQL instructions had the same defect and are corrected too.Verified on MySQL 8.0: the original SQL reproduces error 3140; the fixed
UPDATEsucceeds and the subsequentMODIFY ... FLOATconverts the JSON numbers to300/60.Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Opus 4.8) following the guidelines