vatsrahul1001 opened a new issue, #54339: URL: https://github.com/apache/airflow/issues/54339
### Apache Airflow version 3.0.4 ### If "Other Airflow 2 version" selected, which one? _No response_ ### What happened? when we upgrade from 2.11 to main dag_version table will not have any values and condition in [query](https://github.com/astronomer/airflow/blob/7ea7fcdda67bbbec7fd41977e24c7d3fc9055e91/airflow-core/src/airflow/migrations/versions/0076_3_1_0_make_dag_version_id_non_nullable_in_.py#L46) will not get satisfied. And due to this migration failing [here](https://github.com/astronomer/airflow/blob/7ea7fcdda67bbbec7fd41977e24c7d3fc9055e91/airflow-core/src/airflow/migrations/versions/0076_3_1_0_make_dag_version_id_non_nullable_in_.py#L75) **Migration Logs** ``` traceback (most recent call last): File "/usr/local/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 48, in command return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/opt/airflow/airflow-core/src/airflow/utils/cli.py", line 114, 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 197, in migratedb run_db_migrate_command(args, db.upgradedb, _REVISION_HEADS_MAP) File "/opt/airflow/airflow-core/src/airflow/cli/commands/db_command.py", line 125, in run_db_migrate_command command( File "/opt/airflow/airflow-core/src/airflow/utils/session.py", line 100, in wrapper return func(*args, session=session, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/airflow/airflow-core/src/airflow/utils/db.py", line 988, in upgradedb command.upgrade(config, revision=to_revision or "heads") File "/usr/local/lib/python3.12/site-packages/alembic/command.py", line 483, in upgrade script.run_env() File "/usr/local/lib/python3.12/site-packages/alembic/script/base.py", line 549, in run_env util.load_python_file(self.dir, "env.py") File "/usr/local/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 116, in load_python_file module = load_module_py(module_id, path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/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 999, in exec_module File "<frozen importlib._bootstrap>", line 488, 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/local/lib/python3.12/site-packages/alembic/runtime/environment.py", line 946, in run_migrations self.get_context().run_migrations(**kw) File "/usr/local/lib/python3.12/site-packages/alembic/runtime/migration.py", line 627, in run_migrations step.migration_fn(**kw) File "/opt/airflow/airflow-core/src/airflow/migrations/versions/0076_3_1_0_make_dag_version_id_non_nullable_in_.py", line 74, in upgrade with op.batch_alter_table("task_instance", 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/postgresql.py", line 192, in alter_column super().alter_column( File "/usr/local/lib/python3.12/site-packages/alembic/ddl/impl.py", line 283, in alter_column self._exec( 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) sqlalchemy.exc.IntegrityError: (psycopg2.errors.NotNullViolation) column "dag_version_id" of relation "task_instance" contains null values [SQL: ALTER TABLE task_instance ALTER COLUMN dag_version_id SET NOT NULL] (Background on this error at: https://sqlalche.me/e/14/gkpj) ``` ### What you think should happen instead? _No response_ ### How to reproduce 1. Run breeze with version 2.11.0 2. Migrate to main ### Operating System linux ### Versions of Apache Airflow Providers _No response_ ### Deployment Official Apache Airflow Helm Chart ### 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 - [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]
