---
id: WF-PFM-QRY-011
title: Delete a report and pause its schedules
trigger: >-
  An authorized owner, report manager or granted staff member requests report deletion with the
  version read.
product_area: platform
module: queries
revision: 1
status: draft
design_intent: confirmed
implementation_evidence: observed
source_sha:
  services-platform: ad3f6a6582843008ed0f5a17b131878d15829af1
  react-console: baf6dae382d6f41dce976c7f848667ccc37e076f
inference: []
implements:
  - CAP-PFM-QRY-011
  - CAP-PFM-QRY-015
moves:
  - STATE-PFM-QRY-007
crosses:
  - SVC-PFM-QRY-queries
idempotency: >-
  Repeated deletion receives not found once the report has gone; it cannot repeat the original
  deletion transaction.
concurrency: >-
  Report removal and schedule pauses share a transaction. A stale version or record lock rolls both
  back; already-running work performs its own source checks.
hops:
  - 'n': 1
    actor_or_service: Delete report route
    action: Resolve the visible report and confirm the caller’s modification authority.
    anchor: 'services-platform:modules/queries/services/reports/report-library.ts:removeReport'
    seam: sync
    on_failure: Refuse a hidden report or missing authority.
    left_inconsistent: The report and schedules remain unchanged.
    observer: the person
    provenance: observed
    source: 'services-platform:modules/queries/services/reports/report-access.ts'
  - 'n': 2
    actor_or_service: Report library
    action: >-
      Pause dependent schedules with report_deleted, then remove the report, source rows and roles
      using the read version.
    anchor: 'services-platform:modules/queries/services/reports/report-library.ts:removeReport'
    seam: sync
    on_failure: Rollback pauses and removal on conflict or another transactional failure.
    left_inconsistent: No pause-only partial deletion is committed.
    observer: the schedule list shows report deleted
    provenance: observed
    source: 'services-platform:modules/queries/services/reports/report-library.ts'
  - 'n': 3
    actor_or_service: Database
    action: >-
      Database relationships clear report references from retained files and schedules and release
      saved-query dependencies.
    anchor: >-
      services-platform:modules/queries/db/query-exports.table.ts (query_exports_report_fk ON DELETE
      SET NULL)
    seam: sync
    on_failure: Foreign-key effects follow the deleting transaction.
    left_inconsistent: Completed file objects are retained under their existing access and expiry behavior.
    observer: none
    provenance: observed
    source: 'services-platform:modules/queries/db/query-exports.table.ts'
  - 'n': 4
    actor_or_service: Report renderer (later)
    action: A later renderer checks its queued request against the now-missing report.
    anchor: 'services-platform:modules/queries/services/rendering/render-report.ts'
    seam: queue
    on_failure: Record access_lost for that queued render.
    left_inconsistent: Previously completed files are unaffected by this failed render.
    observer: the person following that export
    provenance: observed
    source: 'services-platform:modules/queries/services/rendering/render-report.ts'
branches:
  - 'Saved-query removal remains refused while report, dashboard or schedule dependencies exist.'
waits: []
evidence:
  - >-
    services-platform at ad3f6a6: modules/queries/services/reports/report-library.ts;
    services/persistence/reports.ts; services/persistence/query-schedules.ts;
    db/query-exports.table.ts; docs/milestones/plans/RPT-M1-plan.md#D9
controls: [TC-AVL-004, TC-AVL-005, TC-AZ-001, TC-AZ-002, TC-AZ-003, TC-AZ-004, TC-AZ-005, TC-DAT-001, TC-DAT-002, TC-DAT-003, TC-DAT-004, TC-DAT-005, TC-IAM-001, TC-IAM-002, TC-IAM-003, TC-IAM-004, TC-IAM-005, TC-IAM-006, TC-LOG-001, TC-LOG-002, TC-LOG-003, TC-LOG-004, TC-LOG-005, TC-MON-001, TC-MON-002, TC-PI-001, TC-PI-002, TC-PI-003, TC-PI-004, TC-PI-005, TC-PRV-001, TC-PRV-002, TC-TEN-001, TC-TEN-002, TC-TEN-003, TC-TEN-004, TC-VEN-001, TC-VEN-002, TC-VEN-003]
---

# Delete a report and pause its schedules

## What It Does

An authorized owner, report manager or granted staff member requests report deletion with the version read. Saved-query removal remains refused while report, dashboard or schedule dependencies exist.

## The Flow

```mermaid
sequenceDiagram
  participant C as Request or schedule
  participant H0 as Delete report route
  participant H1 as Report library
  participant H2 as Database
  participant H3 as Report renderer later
  C->>H0: Resolve the visible report and confirm the caller’s modification authority
  H0->>H1: Pause dependent schedules with report_deleted, then remove the report, source rows and roles using t
  H1->>H2: Database relationships clear report references from retained files and schedules and release saved-q
  opt Later queued rendering
    C-)H3: A later renderer checks its queued request against the now-missing report
  end
```

Resolve the visible report and confirm the caller’s modification authority. Pause dependent schedules with report_deleted, then remove the report, source rows and roles using the read version. Database relationships clear report references from retained files and schedules and release saved-query dependencies. A later renderer checks its queued request against the now-missing report.

## When Something Fails

Refuse a hidden report or missing authority. The report and schedules remain unchanged. Rollback pauses and removal on conflict or another transactional failure. No pause-only partial deletion is committed. Foreign-key effects follow the deleting transaction. Completed file objects are retained under their existing access and expiry behavior. Record access_lost for that queued render. Previously completed files are unaffected by this failed render.

## Idempotency and Concurrency

Repeated deletion receives not found once the report has gone; it cannot repeat the original deletion transaction. Report removal and schedule pauses share a transaction. A stale version or record lock rolls both back; already-running work performs its own source checks.
