Skip to content

Slice 2 (Module 02): Delete document with atomic cascade #10

Description

@mGasiorek998

What to build

Add the ability for a patient to permanently delete one of their documents. The deletion must be atomic: document_shares rows are removed and the documents row is deleted within a single transaction, then the file is removed from disk. If the disk delete fails after the transaction commits, return a 500 with a descriptive body (EH-002 partial-failure path) — the committed DB state is the source of truth. Add a delete button to the document list on /patient/documents.

Acceptance criteria

  • DELETE /documents/:id by the owning patient returns 204; the documents row, all associated document_shares rows, and the UUID file on disk are all gone.
  • The DB removal (documents row + shares rows) occurs inside a single transaction — no observable intermediate state where one is absent and the other is not.
  • Deleting a document that is currently shared with one or more doctors removes the sharing records atomically along with the document row.
  • If the file cannot be deleted from disk after the transaction commits, the endpoint returns 500 with { error: "DELETE_FAILED", message: "Document metadata removed but file could not be deleted from storage" }.
  • DELETE /documents/:id for a document owned by a different patient returns 403.
  • DELETE /documents/:id for a non-existent id returns 404 { error: "DOCUMENT_NOT_FOUND", ... }.
  • The delete button on the /patient/documents UI removes the entry from the list on success.
  • pnpm verify exits 0.

User stories covered

Blocked by

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    afkEligible for the main agent looppriority:2Priority 2qa-readyPR opened, awaiting human QAsliceVertical tracer-bullet slice

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions