Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions .github/actions/migration_tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ runs:
shell: bash
run: |
breeze shell "${{ env.AIRFLOW_2_CMD }}" --use-airflow-version 2.10.5 --answer y &&
breeze shell "${{ env.AIRFLOW_3_CMD }}" --no-db-cleanup
breeze shell "export AIRFLOW__DATABASE__EXTERNAL_DB_MANAGERS=${{env.DB_MANGERS}}
${{ env.AIRFLOW_3_CMD }}" --no-db-cleanup
env:
COMPOSE_PROJECT_NAME: "docker-compose"
AIRFLOW__DATABASE__EXTERNAL_DB_MANAGERS: "airflow.providers.fab.auth_manager.models.db.FABDBManager"
DB_RESET: "false"
DB_MANAGERS: "airflow.providers.fab.auth_manager.models.db.FABDBManager"
AIRFLOW_2_CMD: >-
airflow db reset --skip-init -y &&
airflow db migrate --to-revision heads
Expand All @@ -47,11 +48,12 @@ runs:
shell: bash
run: >
breeze shell "${{ env.AIRFLOW_2_CMD }}" --use-airflow-version 2.10.5 --answer y &&
breeze shell "${{ env.AIRFLOW_3_CMD }}" --no-db-cleanup
breeze shell "export AIRFLOW__DATABASE__EXTERNAL_DB_MANAGERS=${{env.DB_MANGERS}}
${{ env.AIRFLOW_3_CMD }}" --no-db-cleanup
env:
COMPOSE_PROJECT_NAME: "docker-compose"
AIRFLOW__DATABASE__EXTERNAL_DB_MANAGERS: "airflow.providers.fab.auth_manager.models.db.FABDBManager"
DB_RESET: "false"
DB_MANAGERS: "airflow.providers.fab.auth_manager.models.db.FABDBManager"
AIRFLOW_2_CMD: >-
airflow db reset -y
AIRFLOW_3_CMD: >-
Expand All @@ -67,13 +69,14 @@ runs:
- name: "Test ORM migration ${{env.BACKEND}}"
shell: bash
run: >
breeze shell "airflow db reset -y &&
breeze shell "export AIRFLOW__DATABASE__EXTERNAL_DB_MANAGERS=${{env.DB_MANAGERS}} &&
airflow db reset -y &&
airflow db migrate --to-revision heads &&
airflow db downgrade -n 2.7.0 -y &&
airflow db migrate"
env:
COMPOSE_PROJECT_NAME: "docker-compose"
AIRFLOW__DATABASE__EXTERNAL_DB_MANAGERS: "airflow.providers.fab.auth_manager.models.db.FABDBManager"
DB_MANAGERS: "airflow.providers.fab.auth_manager.models.db.FABDBManager"
- name: "Bring compose down again"
shell: bash
run: breeze down
Expand All @@ -82,12 +85,14 @@ runs:
- name: "Test offline migration ${{env.BACKEND}}"
shell: bash
run: >
breeze shell "airflow db reset -y &&
breeze shell
"export AIRFLOW__DATABASE__EXTERNAL_DB_MANAGERS=${{env.DB_MANAGERS}} &&
airflow db reset -y &&
airflow db downgrade -n 2.7.0 -y &&
airflow db migrate -s"
env:
COMPOSE_PROJECT_NAME: "docker-compose"
AIRFLOW__DATABASE__EXTERNAL_DB_MANAGERS: "airflow.providers.fab.auth_manager.models.db.FABDBManager"
DB_MANAGERS: "airflow.providers.fab.auth_manager.models.db.FABDBManager"
if: env.BACKEND != 'sqlite'
- name: "Bring any containers left down"
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion airflow-core/docs/img/airflow_erd.sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1b5221fa589cfc8652242b95f24d218c632168238933b82b533321a217c2447f
066cb891884eea1ee0496b5c507d4a52c20d0440387f9ec8bacb1d616a26e40e
108 changes: 54 additions & 54 deletions airflow-core/docs/img/airflow_erd.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,9 @@ def upgrade():
"""
).bindparams(batch_size=batch_size)
)
row_count = result.rowcount
row_count = 0
if result:
row_count = result.rowcount
if row_count == 0:
break
print(f"Migrated {row_count} task_instance rows in this batch...")
Expand Down
10 changes: 5 additions & 5 deletions airflow-core/src/airflow/utils/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -1219,21 +1219,21 @@ def downgrade(*, to_revision, from_revision=None, show_sql_only=False, session:
config = _get_alembic_config()
# Check if downgrade is less than 3.0.0 and requires that `ab_user` fab table is present
if _revision_greater(config, _REVISION_HEADS_MAP["3.0.0"], to_revision):
if conf.getboolean("core", "unit_test_mode"):
unitest_mode = conf.getboolean("core", "unit_test_mode")
if unitest_mode:
try:
from airflow.providers.fab.auth_manager.models.db import FABDBManager

dbm = FABDBManager(session)
dbm.initdb()
except ImportError:
log.warning("Import error occurred while importing FABDBManager. Skipping the check.")
pass
if not inspect(settings.engine).has_table("ab_user"):
log.error(
return
if not inspect(settings.engine).has_table("ab_user") and not unitest_mode:
raise AirflowException(
"Downgrade to revision less than 3.0.0 requires that `ab_user` table is present. "
"Please add FabDBManager to [core] external_db_managers and run fab migrations before proceeding"
)
return
with create_global_lock(session=session, lock=DBLocks.MIGRATIONS):
if show_sql_only:
log.warning("Generating sql scripts for manual migration.")
Expand Down
Loading