diff --git a/providers/src/airflow/providers/fab/auth_manager/cli_commands/db_command.py b/providers/src/airflow/providers/fab/auth_manager/cli_commands/db_command.py index ad3127c9659f7..74ea13a2f8d70 100644 --- a/providers/src/airflow/providers/fab/auth_manager/cli_commands/db_command.py +++ b/providers/src/airflow/providers/fab/auth_manager/cli_commands/db_command.py @@ -17,22 +17,12 @@ from __future__ import annotations from airflow import settings +from airflow.cli.commands.local_commands.db_command import run_db_downgrade_command, run_db_migrate_command from airflow.providers.fab.auth_manager.models.db import _REVISION_HEADS_MAP, FABDBManager -from airflow.providers.fab.version_compat import AIRFLOW_V_3_0_PLUS from airflow.utils import cli as cli_utils from airflow.utils.providers_configuration_loader import providers_configuration_loaded -def get_db_command(): - """Import the correct db_command module based on the Airflow version.""" - if AIRFLOW_V_3_0_PLUS: - import airflow.cli.commands.local_commands.db_command as db_command - else: - import airflow.cli.commands.db_command as db_command - - return db_command - - @providers_configuration_loaded def resetdb(args): """Reset the metadata database.""" @@ -48,7 +38,7 @@ def migratedb(args): """Migrates the metadata database.""" session = settings.Session() upgrade_command = FABDBManager(session).upgradedb - get_db_command().run_db_migrate_command( + run_db_migrate_command( args, upgrade_command, revision_heads_map=_REVISION_HEADS_MAP, reserialize_dags=False ) @@ -59,4 +49,4 @@ def downgrade(args): """Downgrades the metadata database.""" session = settings.Session() dwongrade_command = FABDBManager(session).downgrade - get_db_command().run_db_downgrade_command(args, dwongrade_command, revision_heads_map=_REVISION_HEADS_MAP) + run_db_downgrade_command(args, dwongrade_command, revision_heads_map=_REVISION_HEADS_MAP) diff --git a/providers/src/airflow/providers/fab/version_compat.py b/providers/src/airflow/providers/fab/version_compat.py deleted file mode 100644 index 103abb8cde7f5..0000000000000 --- a/providers/src/airflow/providers/fab/version_compat.py +++ /dev/null @@ -1,29 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -from __future__ import annotations - - -def get_base_airflow_version_tuple() -> tuple[int, int, int]: - from packaging.version import Version - - from airflow import __version__ - - airflow_version = Version(__version__) - return airflow_version.major, airflow_version.minor, airflow_version.micro - - -AIRFLOW_V_3_0_PLUS = get_base_airflow_version_tuple() >= (3, 0, 0)