Skip to content

Commit

Permalink
fix(backend): delete submission photos while deleting project to avoi…
Browse files Browse the repository at this point in the history
…d foreignkey constraint (#2112)
  • Loading branch information
Sujanadh authored Jan 24, 2025
1 parent 247972b commit 01faae3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/backend/app/db/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1357,6 +1357,12 @@ async def update(
async def delete(cls, db: Connection, project_id: int) -> bool:
"""Delete a project and its related data."""
async with db.cursor() as cur:
await cur.execute(
"""
DELETE FROM submission_photos WHERE project_id = %(project_id)s;
""",
{"project_id": project_id},
)
await cur.execute(
"""
DELETE FROM background_tasks WHERE project_id = %(project_id)s;
Expand Down

0 comments on commit 01faae3

Please sign in to comment.