@@ -33,7 +33,6 @@ def sync_dag_to_db(
3333 bundle_name : str = "testing" ,
3434):
3535 """Sync dags into the database."""
36- from airflow .models .dagbundle import DagBundleModel
3736 from airflow .models .serialized_dag import SerializedDagModel
3837 from airflow .serialization .serialized_objects import (
3938 LazyDeserializedDAG ,
@@ -42,8 +41,11 @@ def sync_dag_to_db(
4241 from airflow .utils .session import create_session
4342
4443 with create_session () as session :
45- session .merge (DagBundleModel (name = bundle_name ))
46- session .flush ()
44+ if AIRFLOW_V_3_1_PLUS :
45+ from airflow .models .dagbundle import DagBundleModel
46+
47+ session .merge (DagBundleModel (name = bundle_name ))
48+ session .flush ()
4749
4850 def _write_dag (dag : DAG ) -> SerializedDAG :
4951 if not SerializedDagModel .has_dag (dag .dag_id ):
@@ -189,7 +191,7 @@ def basic_dag(
189191
190192 dbt_seed >> dbt_run >> dbt_test
191193
192- if AIRFLOW_V_3_1_PLUS :
194+ if AIRFLOW_V_3_0_PLUS :
193195 sync_dag_to_db (dag )
194196 return dag
195197
@@ -301,7 +303,7 @@ def prepare_dbt_project_dir() -> str:
301303
302304 d = generate_dag ()
303305
304- if AIRFLOW_V_3_1_PLUS :
306+ if AIRFLOW_V_3_0_PLUS :
305307 sync_dag_to_db (d )
306308
307309 return d
@@ -443,7 +445,7 @@ def target_connection_dag(
443445
444446 dbt_seed >> dbt_run >> dbt_test
445447
446- if AIRFLOW_V_3_1_PLUS :
448+ if AIRFLOW_V_3_0_PLUS :
447449 sync_dag_to_db (dag )
448450 return dag
449451
@@ -523,7 +525,7 @@ def test_example_basic_dag(
523525 dbt_run .target = "test"
524526 dbt_run .profile = "default"
525527
526- if AIRFLOW_V_3_1_PLUS :
528+ if AIRFLOW_V_3_0_PLUS :
527529 sync_dag_to_db (dag )
528530
529531 dagrun = _create_dagrun (
@@ -576,7 +578,7 @@ def test_example_dbt_project_in_github_dag(
576578 assert dag is not None
577579 assert len (dag .tasks ) == 3
578580
579- if AIRFLOW_V_3_1_PLUS :
581+ if AIRFLOW_V_3_0_PLUS :
580582 sync_dag_to_db (dag )
581583
582584 dagrun = _create_dagrun (
@@ -630,7 +632,7 @@ def test_example_complete_dbt_workflow_dag(
630632 assert dag is not None
631633 assert len (dag .tasks ) == 5
632634
633- if AIRFLOW_V_3_1_PLUS :
635+ if AIRFLOW_V_3_0_PLUS :
634636 sync_dag_to_db (dag )
635637
636638 dagrun = _create_dagrun (
0 commit comments