Aaryan123456679 opened a new pull request, #70235: URL: https://github.com/apache/airflow/pull/70235
Migrating the metadata database to Airflow 2.9.2 (revision `686269002441`) raised `pymysql.err.ProgrammingError` on MySQL when using the PyMySQL driver, because the migration used MySQL's `PREPARE`/`EXECUTE`/`DEALLOCATE PREPARE` dynamic SQL to conditionally drop unique constraints on the `connection` and `dag_run` tables. This syntax is not supported by PyMySQL (see [PyMySQL#202](https://github.com/PyMySQL/PyMySQL/issues/202)), so any deployment using PyMySQL as its MySQL driver could not migrate past this revision. Replaced the dynamic SQL with a plain lookup of existing constraints from `information_schema.TABLE_CONSTRAINTS`, followed by conditional `ALTER TABLE ... DROP INDEX` statements — this works with any MySQL driver. Verified against a real MySQL backend forced to use `mysql+pymysql://`: downgrading to `bff083ad727d` and re-running `airflow db migrate` now completes without error, and the expected unique constraints (`connection_conn_id_uq`, `dag_run_dag_id_*_key`) are present afterward. closes: #43690 --- ##### Was generative AI tooling used to co-author this PR? - [X] Yes — Claude Code (Sonnet 5) Generated-by: Claude Code (Sonnet 5) following [the guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions) -- 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]
