Skip to content

fix(repositories): Fix deletion ordering for ProjectRepository children#115739

Merged
wedamija merged 1 commit into
masterfrom
danf/fix-deletion-ordering
May 18, 2026
Merged

fix(repositories): Fix deletion ordering for ProjectRepository children#115739
wedamija merged 1 commit into
masterfrom
danf/fix-deletion-ordering

Conversation

@wedamija
Copy link
Copy Markdown
Member

Summary

  • Add SeerProjectRepositoryBranchOverride to deletion child relations in project, repository, and project-repository deletion tasks
  • Fix ordering so branch overrides are deleted before SeerProjectRepository, which is deleted before ProjectRepository
  • BulkModelDeletionTask does raw SQL DELETE which bypasses Django CASCADE, so FK children must be explicitly deleted in the correct order

Test plan

  • tests/sentry/deletions/test_project.py — all pass
  • tests/sentry/deletions/test_repository.py — all pass
  • tests/sentry/tasks/test_repository.py — all pass

Fixes SENTRY-5PSY

BulkModelDeletionTask does raw SQL DELETE which bypasses Django CASCADE.
SeerProjectRepositoryBranchOverride has a FK to SeerProjectRepository,
which has a FK to ProjectRepository. When deleting projects or repos,
the branch overrides must be deleted first, then SPR, then
ProjectRepository — otherwise we get IntegrityError from the FK
constraints.

Fixes SENTRY-5PSY

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
@wedamija wedamija requested a review from a team as a code owner May 18, 2026 19:05
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label May 18, 2026
@wedamija wedamija requested a review from a team May 18, 2026 20:01
@wedamija wedamija merged commit 9f6c93a into master May 18, 2026
64 checks passed
@wedamija wedamija deleted the danf/fix-deletion-ordering branch May 18, 2026 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants