phanikumv commented on code in PR #68337:
URL: https://github.com/apache/airflow/pull/68337#discussion_r3393534591
##########
airflow-core/src/airflow/migrations/versions/0117_3_3_0_change_deadline_interval_to_json.py:
##########
@@ -173,20 +188,23 @@ def downgrade():
MySQL:
- Step 1: Convert values
+ Step 1: Convert values. Leave them as JSON numbers; the column is
still JSON
+ here, so casting to a numeric type fails with ER_INVALID_JSON_TEXT
(3140). The
+ cast happens in Step 2 instead.
UPDATE deadline_alert
SET `interval` =
CASE
WHEN JSON_EXTRACT(`interval`, '$.__data__') IS NOT NULL
- THEN CAST(JSON_EXTRACT(`interval`, '$.__data__') AS
DOUBLE)
+ THEN JSON_EXTRACT(`interval`, '$.__data__')
WHEN JSON_EXTRACT(`interval`, '$.__classname__') IS NULL
- THEN CAST(`interval` AS DOUBLE)
+ THEN `interval`
ELSE NULL
END;
- Step 2: Convert column type
+ Step 2: Convert column type. This casts the JSON numbers to FLOAT
(the original
+ pre-upgrade type, matching the online migration).
ALTER TABLE deadline_alert
- MODIFY COLUMN `interval` DOUBLE;
+ MODIFY COLUMN `interval` FLOAT;
Review Comment:
Online retype preserves NOT NULL (existing_nullable=False), but this manual
instruction is just MODIFY COLUMN interval FLOAT — following it literally drops
the constraint. MODIFY COLUMN interval FLOAT NOT NULL to match the online
migration
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]