Repository navigation
Closed
Labels
affected_version:3.2Use for reporting issues with 3.2area:corearea:db-migrationsPRs with DB migrationkind:bugThis is a clearly a bugpriority:highHigh priority bug that should be patched quickly but does not require immediate new release
Description
Apache Airflow version
3.2.0b1
If "Other Airflow 3 version" selected, which one?
No response
What happened?
Performing downgrade from 3.2.0b1 to 3.1.8 with SQlite is broken
Welcome to your tmux based running Airflow environment (courtesy of Breeze).
To stop Airflow and exit tmux, just type 'stop_airflow'.
If you want to build webserver assets dynamically, run start-airflow command with --dev-mode
[Breeze:3.10.20] root@3bb4a8f93556:/opt/airflow$ airflow db downgrade -n 3.1.8
2026-03-12T11:07:40.013390Z [info ] setup plugin alembic.autogenerate.schemas [alembic.runtime.plugins] loc=plugins.py:37
2026-03-12T11:07:40.013532Z [info ] setup plugin alembic.autogenerate.tables [alembic.runtime.plugins] loc=plugins.py:37
2026-03-12T11:07:40.013595Z [info ] setup plugin alembic.autogenerate.types [alembic.runtime.plugins] loc=plugins.py:37
2026-03-12T11:07:40.013645Z [info ] setup plugin alembic.autogenerate.constraints [alembic.runtime.plugins] loc=plugins.py:37
2026-03-12T11:07:40.013707Z [info ] setup plugin alembic.autogenerate.defaults [alembic.runtime.plugins] loc=plugins.py:37
2026-03-12T11:07:40.013756Z [info ] setup plugin alembic.autogenerate.comments [alembic.runtime.plugins] loc=plugins.py:37
Performing downgrade with database sqlite:////root/airflow/sqlite/airflow.db
Warning: About to reverse schema migrations for the airflow metastore. Please ensure you have backed up your database before any upgrade or downgrade operation. Proceed? (y/n)
y
2026-03-12T11:07:42.745671Z [info ] Attempting downgrade to revision 509b94a1042d [airflow.utils.db] loc=db.py:1343
/opt/airflow/airflow-core/src/airflow/migrations/versions/0094_3_2_0_replace_deadline_inline_callback_with_fkey.py:37 DeprecatedImportWarning: The `airflow.serialization.serde.deserialize` attribute is deprecated. Please use `'airflow.sdk.serde.deserialize'`.
2026-03-12T11:07:42.845887Z [info ] Applying downgrade migrations to Airflow database. [airflow.utils.db] loc=db.py:1370
2026-03-12T11:07:42.847463Z [info ] Context impl SQLiteImpl. [alembic.runtime.migration] loc=migration.py:210
2026-03-12T11:07:42.847573Z [info ] Will assume non-transactional DDL. [alembic.runtime.migration] loc=migration.py:213
/opt/airflow/airflow-core/src/airflow/migrations/versions/0094_3_2_0_replace_deadline_inline_callback_with_fkey.py:37 DeprecatedImportWarning: The `airflow.serialization.serde.deserialize` attribute is deprecated. Please use `'airflow.sdk.serde.deserialize'`.
2026-03-12T11:07:42.907748Z [info ] Running downgrade 6222ce48e289 -> 134de42d3cb0, Add partition fields to DagModel. [alembic.runtime.migration] loc=migration.py:621
Traceback (most recent call last):
File "/usr/python/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1967, in _exec_single_context
self.dialect.do_execute(
File "/usr/python/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 952, in do_execute
cursor.execute(statement, parameters)
sqlite3.IntegrityError: FOREIGN KEY constraint failed
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/python/bin/airflow", line 10, in <module>
sys.exit(main())
File "/opt/airflow/airflow-core/src/airflow/__main__.py", line 55, in main
args.func(args)
File "/opt/airflow/airflow-core/src/airflow/cli/cli_config.py", line 49, in command
return func(*args, **kwargs)
File "/opt/airflow/airflow-core/src/airflow/utils/cli.py", line 113, in wrapper
return f(*args, **kwargs)
File "/opt/airflow/airflow-core/src/airflow/utils/providers_configuration_loader.py", line 54, in wrapped_function
return func(*args, **kwargs)
File "/opt/airflow/airflow-core/src/airflow/cli/commands/db_command.py", line 213, in downgrade
run_db_downgrade_command(args, db.downgrade, _REVISION_HEADS_MAP)
File "/opt/airflow/airflow-core/src/airflow/cli/commands/db_command.py", line 188, in run_db_downgrade_command
command(to_revision=to_revision, from_revision=from_revision, show_sql_only=args.show_sql_only)
File "/opt/airflow/airflow-core/src/airflow/utils/session.py", line 100, in wrapper
return func(*args, session=session, **kwargs) # type: ignore[arg-type]
File "/opt/airflow/airflow-core/src/airflow/utils/db.py", line 1371, in downgrade
command.downgrade(config, revision=to_revision, sql=show_sql_only)
File "/usr/python/lib/python3.10/site-packages/alembic/command.py", line 530, in downgrade
script.run_env()
File "/usr/python/lib/python3.10/site-packages/alembic/script/base.py", line 545, in run_env
util.load_python_file(self.dir, "env.py")
File "/usr/python/lib/python3.10/site-packages/alembic/util/pyfiles.py", line 116, in load_python_file
module = load_module_py(module_id, path)
File "/usr/python/lib/python3.10/site-packages/alembic/util/pyfiles.py", line 136, in load_module_py
spec.loader.exec_module(module) # type: ignore
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/opt/airflow/airflow-core/src/airflow/migrations/env.py", line 138, in <module>
run_migrations_online()
File "/opt/airflow/airflow-core/src/airflow/migrations/env.py", line 132, in run_migrations_online
context.run_migrations()
File "<string>", line 8, in run_migrations
File "/usr/python/lib/python3.10/site-packages/alembic/runtime/environment.py", line 969, in run_migrations
self.get_context().run_migrations(**kw)
File "/usr/python/lib/python3.10/site-packages/alembic/runtime/migration.py", line 626, in run_migrations
step.migration_fn(**kw)
File "/opt/airflow/airflow-core/src/airflow/migrations/versions/0107_3_2_0_add_partition_fields_to_dag.py", line 56, in downgrade
with op.batch_alter_table("dag", schema=None) as batch_op:
File "/usr/python/lib/python3.10/contextlib.py", line 142, in __exit__
next(self.gen)
File "/usr/python/lib/python3.10/site-packages/alembic/operations/base.py", line 408, in batch_alter_table
impl.flush()
File "/usr/python/lib/python3.10/site-packages/alembic/operations/batch.py", line 163, in flush
batch_impl._create(self.impl)
File "/usr/python/lib/python3.10/site-packages/alembic/operations/batch.py", line 468, in _create
op_impl.drop_table(self.table)
File "/usr/python/lib/python3.10/site-packages/alembic/ddl/impl.py", line 465, in drop_table
self._exec(schema.DropTable(table, **kw))
File "/usr/python/lib/python3.10/site-packages/alembic/ddl/impl.py", line 256, in _exec
return conn.execute(construct, params)
File "/usr/python/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1419, in execute
return meth(
File "/usr/python/lib/python3.10/site-packages/sqlalchemy/sql/ddl.py", line 187, in _execute_on_connection
return connection._execute_ddl(
File "/usr/python/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1530, in _execute_ddl
ret = self._execute_context(
File "/usr/python/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1846, in _execute_context
return self._exec_single_context(
File "/usr/python/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1986, in _exec_single_context
self._handle_dbapi_exception(
File "/usr/python/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 2363, in _handle_dbapi_exception
raise sqlalchemy_exception.with_traceback(exc_info[2]) from e
File "/usr/python/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1967, in _exec_single_context
self.dialect.do_execute(
File "/usr/python/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 952, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.IntegrityError: (sqlite3.IntegrityError) FOREIGN KEY constraint failed
[SQL:
DROP TABLE dag]
(Background on this error at: https://sqlalche.me/e/20/gkpj)
[Breeze:3.10.20] root@3bb4a8f93556:/opt/airflow$What you think should happen instead?
No response
How to reproduce
Steps to repro:
- Run airflow instance with command
breeze start-airflow --executor CeleryExecutor --backend SQlite --load-example-dags - Make some dagruns, upgrade to 3.2.0b1
- Downgrade back to 3.1.8 with command
airflow db downgrade - Notice error
Operating System
Linux
Versions of Apache Airflow Providers
No response
Deployment
Other
Deployment details
No response
Anything else?
No response
Are you willing to submit PR?
- Yes I am willing to submit a PR!
Code of Conduct
- I agree to follow this project's Code of Conduct
Metadata
Metadata
Assignees
Labels
affected_version:3.2Use for reporting issues with 3.2area:corearea:db-migrationsPRs with DB migrationkind:bugThis is a clearly a bugpriority:highHigh priority bug that should be patched quickly but does not require immediate new release
Activity