Pranaykarvi opened a new pull request, #63494:
URL: https://github.com/apache/airflow/pull/63494

   ## Problem
   
   During `airflow db downgrade` from 3.2 to 3.1 on MySQL, the downgrade fails 
with:
   ```
   MySQLdb.ProgrammingError: (1064) You have an error in your SQL syntax ... 
near ', callback_def\ndeadline_alert\n' at line 1
   ```
   
   The raw SQL queries in migration 
`0101_3_2_0_ui_improvements_for_deadlines.py` use `interval` as an unquoted 
column name. `interval` is a reserved keyword in MySQL, causing a syntax error.
   
   ## Fix
   
   Replaced both raw `sa.text()` queries that reference `interval` with 
SQLAlchemy `sa.table()` / `sa.select()` expressions. SQLAlchemy automatically 
quotes reserved keywords per dialect (backticks on MySQL, double-quotes on 
PostgreSQL), making the queries database-agnostic.
   
   A shared `deadline_alert_table` definition is added at module level and 
reused in both `validate_written_data()` and the downgrade batch loop.
   
   ## Testing
   
   Reproduces with MySQL backend when downgrading from 3.2.0b1 to 3.1.x with a 
DAG containing `DeadlineAlert`.
   
   Fixes #63439


-- 
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]

Reply via email to