anmolxlight opened a new pull request, #66674: URL: https://github.com/apache/airflow/pull/66674
## What Fixes external DB manager upgrades when manager-owned tables already exist but the manager-specific Alembic version table does not. Previously, `BaseDBManager.upgradedb()` treated that state as an empty database, called `create_db_from_orm()`, and stamped the manager to head. Because `metadata.create_all()` is a no-op for existing tables, migration bodies were skipped while Alembic believed the schema was current. ## Why This breaks upgrades such as Airflow 3.1 + edge3 1.x to Airflow 3.2 + edge3 3.4, where `edge_job`, `edge_worker`, and `edge_logs` already exist from the pre-`EdgeDBManager` era, but `alembic_version_edge3` does not. The old path stamped edge3 to head without applying migrations that add columns like `edge_worker.concurrency` and `edge_job.team_name`. ## How - Detect existing manager-owned tables before falling back to ORM creation in `BaseDBManager.upgradedb()`. - If tables exist with no manager revision, stamp the manager to its base revision, then run Alembic upgrade to heads. - Apply the same behavior to `FABDBManager.upgradedb()`, which has its own upgrade implementation. - Add generic `BaseDBManager` tests plus edge3 and FAB coverage. ## Tests - `uv run ruff check airflow-core/src/airflow/utils/db_manager.py airflow-core/tests/unit/utils/test_db_manager.py providers/edge3/tests/unit/edge3/models/test_db.py providers/fab/src/airflow/providers/fab/auth_manager/models/db.py providers/fab/tests/unit/fab/auth_manager/models/test_db.py` - `uv run --project airflow-core pytest airflow-core/tests/unit/utils/test_db_manager.py -q` - `uv run --project providers/edge3 pytest providers/edge3/tests/unit/edge3/models/test_db.py -q` - `uv run --project providers/fab pytest providers/fab/tests/unit/fab/auth_manager/models/test_db.py -q` Fixes: #66524 -- 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]
