vinitpayal opened a new issue, #58894: URL: https://github.com/apache/airflow/issues/58894
### Apache Airflow version
3.1.3
### If "Other Airflow 2/3 version" selected, which one?
_No response_
### What happened?
We had an existing Airflow instance running with Airflow 2.11 and using
MySQL 8.0.35 as metadata database.
Now while upgrading it gives error in migrating database in
**_/airflow/providers/fab/migrations/versions/0001_1_4_0_create_ab_tables_if_missing.py_**,
index creation query here is wrong as MySQL doesn't support syntax `CREATE
INDEX IF NOT EXISTS`
```
│ File
"/usr/local/lib/python3.12/site-packages/airflow/providers/fab/migrations/versions/0001_1_4_0_create_ab_tables_if_missing.py",
line 141, in upgrade
│
│ with op.batch_alter_table("ab_group_role", schema=None) as batch_op:
│
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
│
│ File "/usr/local/lib/python3.12/contextlib.py", line 144, in __exit__
│
│ next(self.gen)
│
│ File
"/usr/local/lib/python3.12/site-packages/alembic/operations/base.py", line 397,
in batch_alter_table
│
│ impl.flush()
│
│ File
"/usr/local/lib/python3.12/site-packages/alembic/operations/batch.py", line
115, in flush
│
│ fn(*arg, **kw)
│
│ File "/usr/local/lib/python3.12/site-packages/alembic/ddl/impl.py", line
452, in create_index
│
│ self._exec(schema.CreateIndex(index, **kw))
│
│ File "/usr/local/lib/python3.12/site-packages/alembic/ddl/impl.py", line
246, in _exec
│
│ return conn.execute(construct, params)
│
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
│
│ File
"/usr/local/lib/python3.12/site-packages/sqlalchemy/future/engine.py", line
286, in execute
│
│ return self._execute_20(
│
│ ^^^^^^^^^^^^^^^^^
│
│ File
"/usr/local/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1710,
in _execute_20
│
│ return meth(self, args_10style, kwargs_10style, execution_options)
│
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
│
│ File "/usr/local/lib/python3.12/site-packages/sqlalchemy/sql/ddl.py",
line 80, in _execute_on_connection
│
│ return connection._execute_ddl(
│
│ ^^^^^^^^^^^^^^^^^^^^^^^^
│
│ File
"/usr/local/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1477,
in _execute_ddl
│
│ ret = self._execute_context(
│
│ ^^^^^^^^^^^^^^^^^^^^^^
│
│ File
"/usr/local/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1953,
in _execute_context
│
│ self._handle_dbapi_exception(
│
│ File
"/usr/local/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2134,
in _handle_dbapi_exception
│
│ util.raise_(
│
│ File
"/usr/local/lib/python3.12/site-packages/sqlalchemy/util/compat.py", line 211,
in raise_
│
│ raise exception
│
│ File
"/usr/local/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1910,
in _execute_context
│
│ self.dialect.do_execute(
│
│ File
"/usr/local/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line
736, in do_execute
│
│ cursor.execute(statement, parameters)
│
│ File "/usr/local/lib/python3.12/site-packages/MySQLdb/cursors.py", line
179, in execute
│
│ res = self._query(mogrified_query)
│
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
│
│ File "/usr/local/lib/python3.12/site-packages/MySQLdb/cursors.py", line
330, in _query
│
│ db.query(q)
│
│ File "/usr/local/lib/python3.12/site-packages/MySQLdb/connections.py",
line 280, in query
│
│ _mysql.connection.query(self, query)
│
│ sqlalchemy.exc.ProgrammingError: (MySQLdb.ProgrammingError) (1064, "You
have an error in your SQL syntax; check the manual that corresponds to your
MySQL server version for the right syntax to use near 'IF NOT EXISTS
idx_group_id ON ab_group_role (gr │
│ [SQL: CREATE INDEX IF NOT EXISTS idx_group_id ON ab_group_role (group_id)]
│
│ (Background on this error at: https://sqlalche.me/e/14/f405)
```
### What you think should happen instead?
Migrations should work with MySQL(I think an issue with the alembic which we
are using to apply the migrations).
### How to reproduce
- Create an airflow instance with version 2.11 and MySQL being database
- Upgrade airflow version to 3.1.3/3.1.2
- Will encounter the migration error
### Operating System
Debian GNU/Linux 12 (bookworm)
### Versions of Apache Airflow Providers
apache-airflow-providers-amazon==9.16.0
apache-airflow-providers-cncf-kubernetes==10.7.0
apache-airflow-providers-common-compat==1.8.0
apache-airflow-providers-common-io==1.6.4
apache-airflow-providers-common-sql==1.28.2
apache-airflow-providers-fab==3.0.1
apache-airflow-providers-http==5.4.0
apache-airflow-providers-mysql==6.3.4
apache-airflow-providers-slack==9.4.0
apache-airflow-providers-smtp==2.3.1
apache-airflow-providers-standard==1.9.1
### Deployment
Official Apache Airflow Helm Chart
### Deployment details
_No response_
### Anything else?
_No response_
### Are you willing to submit PR?
- [x] Yes I am willing to submit a PR!
### Code of Conduct
- [x] I agree to follow this project's [Code of
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
--
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]
