Skip to content

Commit

Permalink
Allow 'dag_version' table to be deleted by db clean command
Browse files Browse the repository at this point in the history
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 committed Nov 26, 2024
1 parent a18bcd7 commit cd6307e
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 cd6307e

Please sign in to comment.