Skip to content

Add maintenance mode for SCCN migration window #342

Closed

Description

@neuromechanist

Problem

During the SCCN Cloudflare migration (Epic #314, Phase 6 D1 data sync + Phase 8 DNS cutover), we need to freeze writes on the personal-account backend so the D1 dump captures a consistent snapshot. Any writes during the dump/restore window risk silent data loss.

Solution

Add a maintenance-mode middleware to the backend that can be toggled via the MAINTENANCE_MODE env var (off | read-only | full) and redeployed.

Modes

  • off (default): normal operation
  • read-only: block all POST/PUT/DELETE except admin endpoints; GETs still work so users can clone/download
  • full: 503 on everything except /health, /notices, and admin auth (so admins can toggle back)

Response shape — 503 with Retry-After header and JSON body:

{
  "error": "Service Unavailable",
  "message": "NEMAR is in maintenance mode for the SCCN migration.",
  "mode": "read-only",
  "eta": null
}

Scope

  • backend/src/middleware/maintenance.ts with 3 modes
  • MAINTENANCE_MODE in both wrangler.toml and wrangler-sccn.toml
  • CLI detects maintenance 503 and shows a friendly banner (no stack trace)
  • Tests for each mode (no mocks)

Context

Blocks Epic #314 Phase 6 (D1 data migration) and Phase 8 (DNS cutover). Hotfix branched off main since production needs it first.

Activity

  1. added
    P1
    feature
    on Apr 17, 2026
  2. added 2 commits that reference this issue on Apr 17, 2026
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

    P1feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions