Skip to content

feat: add database health check to readiness probe and admin db-diagn… - #585

Open
playmaker410 wants to merge 2 commits into
scout-off:mainfrom
playmaker410:feat/db-health-check-and-diagnostics
Open

feat: add database health check to readiness probe and admin db-diagn…#585
playmaker410 wants to merge 2 commits into
scout-off:mainfrom
playmaker410:feat/db-health-check-and-diagnostics

Conversation

@playmaker410

Copy link
Copy Markdown

…ostics endpoint

  • Add checkDbHealth() in src/db/index.ts with heartbeat upsert and PRAGMA quick_check
  • Integrate DB health check into readiness probes (/ready and /health/readiness)
  • Add GET /api/admin/db-diagnostics endpoint returning file size, last migration, and full integrity check
  • Add tests covering healthy and simulated-failure scenarios

…ostics endpoint

- Add checkDbHealth() in src/db/index.ts with heartbeat upsert and PRAGMA quick_check
- Integrate DB health check into readiness probes (/ready and /health/readiness)
- Add GET /api/admin/db-diagnostics endpoint returning file size, last migration, and full integrity check
- Add tests covering healthy and simulated-failure scenarios
@Petah1

Petah1 commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

no tags

…dpoint

- Add checkDbHealth() to src/db/index.ts: upserts a heartbeat row into
  _healthcheck and runs PRAGMA quick_check for a cheap per-request probe
- Add getDbFileSize(), getLastMigration(), getDbIntegrityCheck() helpers
  for the deeper admin diagnostics endpoint
- Wire probeDb() into /ready, /health/readiness, and /health in app.ts
  so DB writability/integrity failures cause readiness to report 503
- Add GET /api/admin/db-diagnostics (admin-only) returning file size,
  last migration applied, and full PRAGMA integrity_check output
- Add tests/routes/dbDiagnostics.test.ts covering:
  - checkDbHealth() healthy path and simulated read-only failure
  - /ready 503 when DB probe fails (mocked checkDbHealth)
  - GET /api/admin/db-diagnostics with 401/403/200 auth scenarios
  - getDbFileSize / getLastMigration / getDbIntegrityCheck unit tests
- Update tests/routes/health.test.ts to assert db field in services
- Fix TypeScript lint: use unknown instead of any in catch blocks

Closes #<issue>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants