Benjamin's decision Nr. 17 (docgen#6 comment 17878, V-g): reports must not be deleted automatically when a workspace is deleted.
Before:DELETE /v1/admin/tenants/{id} (staff only, archived workspaces only) deleted the workspace's intake reports with it, because every intake table cascades from tenants.
Now:
The purge checks first, before any document file or Keycloak account is removed. It answers 409 intake_retained while the workspace has reports.
Migration 0030:intake_reports.tenant_id changes to ON DELETE RESTRICT, so the database refuses too. DeleteTenant maps that to ErrConflict.
CountIntakeReports exists on both stores.
How long reports are then kept, and who may delete them later, is a retention question that isn't decided yet. Until it is, they stay.
Effects:
Prod: no workspace there has intake reports today (the intake is off), so nothing changes.
Stage: a purge of a workspace that has test reports is refused from now on.
The breakpilot prod tenant plan isn't affected: it creates a new workspace and doesn't purge one (control-center confirmed).
Tests:
TestPurgeKeepsIntakeReports: refused, nothing removed, the store refuses as well.
Benjamin's decision Nr. 17 (docgen#6 comment 17878, V-g): reports must not be deleted automatically when a workspace is deleted.
**Before:** `DELETE /v1/admin/tenants/{id}` (staff only, archived workspaces only) deleted the workspace's intake reports with it, because every intake table cascades from `tenants`.
**Now:**
- The purge checks first, before any document file or Keycloak account is removed. It answers **409 `intake_retained`** while the workspace has reports.
- **Migration 0030:** `intake_reports.tenant_id` changes to `ON DELETE RESTRICT`, so the database refuses too. `DeleteTenant` maps that to `ErrConflict`.
- `CountIntakeReports` exists on both stores.
How long reports are then kept, and who may delete them later, is a retention question that isn't decided yet. Until it is, they stay.
**Effects:**
- **Prod:** no workspace there has intake reports today (the intake is off), so nothing changes.
- **Stage:** a purge of a workspace that has test reports is refused from now on.
- **The `breakpilot` prod tenant plan** isn't affected: it creates a new workspace and doesn't purge one (control-center confirmed).
**Tests:**
- `TestPurgeKeepsIntakeReports`: refused, nothing removed, the store refuses as well.
- `TestIntakeStore` now expects the reports to stay.
- Postgres variants run in CI.
Control-center was told before this PR.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_014aRnCGqELxoix5TfpX8Ejf
Purging an archived workspace deleted its intake reports with it: every
intake table cascaded from tenants. Benjamin's decision Nr. 17 (docgen#6
17878, V-g): no automatic deletion of the reports when a workspace is
deleted.
The purge now refuses first, before any file or account is removed:
409 intake_retained while the workspace has reports. Migration 0030 makes
the database refuse as well (intake_reports → tenants ON DELETE RESTRICT),
and DeleteTenant maps that to ErrConflict. CountIntakeReports on both
stores.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014aRnCGqELxoix5TfpX8Ejf
sharang
merged commit b28d564867 into main2026-11-12 13:33:11 +00:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Benjamin's decision Nr. 17 (docgen#6 comment 17878, V-g): reports must not be deleted automatically when a workspace is deleted.
Before:
DELETE /v1/admin/tenants/{id}(staff only, archived workspaces only) deleted the workspace's intake reports with it, because every intake table cascades fromtenants.Now:
intake_retainedwhile the workspace has reports.intake_reports.tenant_idchanges toON DELETE RESTRICT, so the database refuses too.DeleteTenantmaps that toErrConflict.CountIntakeReportsexists on both stores.How long reports are then kept, and who may delete them later, is a retention question that isn't decided yet. Until it is, they stay.
Effects:
breakpilotprod tenant plan isn't affected: it creates a new workspace and doesn't purge one (control-center confirmed).Tests:
TestPurgeKeepsIntakeReports: refused, nothing removed, the store refuses as well.TestIntakeStorenow expects the reports to stay.Control-center was told before this PR.
🤖 Generated with Claude Code
https://claude.ai/code/session_014aRnCGqELxoix5TfpX8Ejf