From 9a0d9c570bb238fa7f2b799b4ceced637b88f5eb Mon Sep 17 00:00:00 2001 From: Jed Cunningham <66968678+jedcunningham@users.noreply.github.com> Date: Mon, 6 May 2024 16:25:00 -0400 Subject: [PATCH] Simpler error message when trying to offline migrate with sqlite (#39441) --- airflow/utils/db.py | 2 +- tests/utils/test_db.py | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/airflow/utils/db.py b/airflow/utils/db.py index e20836f0e2feb..e7afb04014e24 100644 --- a/airflow/utils/db.py +++ b/airflow/utils/db.py @@ -1535,7 +1535,7 @@ def _revisions_above_min_for_offline(config, revisions) -> None: """ dbname = settings.engine.dialect.name if dbname == "sqlite": - raise AirflowException("Offline migration not supported for SQLite.") + raise SystemExit("Offline migration not supported for SQLite.") min_version, min_revision = ("2.2.0", "7b2661a43ba3") if dbname == "mssql" else ("2.0.0", "e959f08ac86c") # Check if there is history between the revisions and the start revision diff --git a/tests/utils/test_db.py b/tests/utils/test_db.py index 0b4347f589d22..7312906abfceb 100644 --- a/tests/utils/test_db.py +++ b/tests/utils/test_db.py @@ -34,7 +34,6 @@ from sqlalchemy import MetaData, Table from sqlalchemy.sql import Select -from airflow.exceptions import AirflowException from airflow.models import Base as airflow_base from airflow.settings import engine from airflow.utils.db import ( @@ -180,7 +179,7 @@ def test_offline_upgrade_fails_for_migration_less_than_2_0_0_head(self): def test_sqlite_offline_upgrade_raises_with_revision(self): with mock.patch("airflow.utils.db.settings.engine.dialect") as dialect: dialect.name = "sqlite" - with pytest.raises(AirflowException, match="Offline migration not supported for SQLite"): + with pytest.raises(SystemExit, match="Offline migration not supported for SQLite"): upgradedb(from_revision="e1a11ece99cc", to_revision="54bebd308c5f", show_sql_only=True) def test_offline_upgrade_fails_for_migration_less_than_2_2_0_head_for_mssql(self):