Skip to content

Commit

Permalink
Allow 'dag_version' table to be deleted by db clean command (apache#4…
Browse files Browse the repository at this point in the history
…4389)

Deleting a dag would cascade delete dag_version table along with
serialized_dag model and dagcode. However, we should be able to
delete dag_version directly. I didn't add dag_code or serdag model
because it won't make sense to have an existing dag_version without
a corresponding dagcode and serdag
  • Loading branch information
ephraimbuddy authored and ArshiaZr committed Nov 27, 2024
1 parent 112b7ad commit 59b5979
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 1 deletion.
1 change: 1 addition & 0 deletions airflow/utils/db_cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ def readable_config(self):
_TableConfig(table_name="celery_taskmeta", recency_column_name="date_done"),
_TableConfig(table_name="celery_tasksetmeta", recency_column_name="date_done"),
_TableConfig(table_name="trigger", recency_column_name="created_date"),
_TableConfig(table_name="dag_version", recency_column_name="created_at"),
]

if conf.get("webserver", "session_backend") == "database":
Expand Down
1 change: 0 additions & 1 deletion tests/utils/test_db_cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,6 @@ def test_no_models_missing(self):
"rendered_task_instance_fields", # foreign key with TI
"dag_priority_parsing_request", # Records are purged once per DAG Processing loop, not a
# significant source of data.
"dag_version", # self-maintaining
}

from airflow.utils.db_cleanup import config_dict
Expand Down

0 comments on commit 59b5979

Please sign in to comment.