Skip to content

Commit

Permalink
Simpler error message when trying to offline migrate with sqlite (#39441
Browse files Browse the repository at this point in the history
)
  • Loading branch information
jedcunningham authored May 6, 2024
1 parent a74b5f0 commit 9a0d9c5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion airflow/utils/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions tests/utils/test_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 9a0d9c5

Please sign in to comment.