Skip to main content

Case Deletion Impact

This page explains what happens when a case is deleted, so teams can safely use delete-based rollback.

Overview

When you delete a case, CaseBright performs:

  1. App-level pre-cleanup for parent-child records.
  2. Database delete of the case.
  3. Cascade deletes from database foreign keys.
  4. Best-effort S3 cleanup for case document files.

Deleted Automatically

The following are removed as part of delete flow (directly or via cascade):

  • Case steps
  • Step assignments (staff/group/client)
  • Case assignments and group case assignments
  • Case custom field definitions and values
  • Case comments and comment attachments
  • Case activity events
  • Case document collections and requirements
  • Case files records
  • Form instances linked to the case (and their sections/fields)
  • Step-linked artifacts:
    • Step attachments
    • Submissions
    • Fee items and fee item attachment links
    • Service of document records
    • Step due date rules
    • Recurrence history
    • Case contracts and contract signers

Detached (Not Deleted)

The following records are preserved but detached from the deleted case (caseId becomes null):

  • Tasks linked to the case
  • Tickets linked to the case
  • Client conversations linked to the case
  • Invoices linked to the case
  • Retainer ledger entries linked to the case

If other cases reference the deleted record as convertedFromLeadId, those references are nulled before delete to avoid relation errors.

Storage Cleanup Notes

Current delete flow explicitly collects and deletes S3 objects for case_files.

Potentially related files in other tables (for example step attachments, comment attachments, generated contract files) rely on separate lifecycle cleanup and are not part of the same explicit S3 collection pass.

Recommendation Before Delete Rollback

Before using delete as rollback in production:

  1. Export affected cases for backup.
  2. Confirm if invoices/tasks/tickets should be retained (they are detached, not deleted).
  3. Confirm if extra S3 cleanup is required for attachments/contracts in your environment.