feat: ensure deletion of custom fields and values when a board is deleted

This commit is contained in:
Abhimanyu Saharan
2026-02-16 00:44:40 +05:30
parent 1d63bd0148
commit 47dfc1b52f
2 changed files with 18 additions and 1 deletions

View File

@@ -23,6 +23,7 @@ from app.models.board_webhooks import BoardWebhook
from app.models.organization_board_access import OrganizationBoardAccess
from app.models.organization_invite_board_access import OrganizationInviteBoardAccess
from app.models.tag_assignments import TagAssignment
from app.models.task_custom_fields import BoardTaskCustomField, TaskCustomFieldValue
from app.models.task_dependencies import TaskDependency
from app.models.task_fingerprints import TaskFingerprint
from app.models.tasks import Task
@@ -84,6 +85,12 @@ async def delete_board(session: AsyncSession, *, board: Board) -> OkResponse:
col(TagAssignment.task_id).in_(task_ids),
commit=False,
)
await crud.delete_where(
session,
TaskCustomFieldValue,
col(TaskCustomFieldValue.task_id).in_(task_ids),
commit=False,
)
# Keep teardown ordered around FK/reference chains so dependent rows are gone
# before deleting their parent task/agent/board records.
await crud.delete_where(
@@ -129,6 +136,11 @@ async def delete_board(session: AsyncSession, *, board: Board) -> OkResponse:
OrganizationInviteBoardAccess,
col(OrganizationInviteBoardAccess.board_id) == board.id,
)
await crud.delete_where(
session,
BoardTaskCustomField,
col(BoardTaskCustomField.board_id) == board.id,
)
# Tasks reference agents and have dependent records.
# Delete tasks before agents.