Skip to content

feat(health): /healthz reports last applied migration (P4-I)#82

Merged
CryptoJones merged 1 commit into
masterfrom
feat/healthz-migration
May 18, 2026
Merged

feat(health): /healthz reports last applied migration (P4-I)#82
CryptoJones merged 1 commit into
masterfrom
feat/healthz-migration

Conversation

@CryptoJones
Copy link
Copy Markdown
Owner

Part of architect audit issue #73 — iteration P4-I.

Summary

  • GET /healthz body gains migration — last applied migration name from SequelizeMeta. Lets a rolling-deploy caller verify every pod is at the expected schema version.
  • Migration-read failure does NOT flip status to degraded — the DB is still up. Just falls back to migration: null.
  • OpenAPI spec updated.

Test plan

  • New healthz case asserts migration key present + null|string.
  • Full suite: 358 pass / 4 skip.

This code proudly made in Nebraska. GO BIG RED! 🌽 https://xkcd.com/2347/

Architect audit P4-I. `GET /healthz` body gains a `migration` field
carrying the lex-highest entry from `SequelizeMeta` (e.g.
`"20260519000000-idempotency-keys"`). Sequelize-cli timestamp-prefixes
migration filenames so lex order matches apply order — pulling the
top row is equivalent to "last applied" without a separate marker.

Use cases:
- Rolling-deploy verification: poll /healthz across pods, confirm
  every instance is at the expected migration before flipping traffic.
- Drift detection: a stuck pod that didn't pick up a migration shows
  up as a different `migration` value in the response.
- Compliance/audit: timestamps the schema version visible at probe time.

Implementation notes:
- The migration query is wrapped in its own try/catch. A failure to
  read SequelizeMeta (missing table on a fresh DB, perms, etc.) does
  NOT flip `status` to `degraded` — the DB itself is up, so the API
  is functional. `migration` just falls back to `null`.
- No new query when the DB ping fails — `migration` stays null and
  the outer 503 covers the case.
- OpenAPI spec updated to document the new field.

Tests:
- New healthz case asserts `migration` is present and is either
  `null` or a string. Specific values are covered by integration
  tests against a real DB.
- Full suite: 358 pass / 4 skip.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@CryptoJones CryptoJones merged commit 4a0879d into master May 18, 2026
3 checks passed
@CryptoJones CryptoJones deleted the feat/healthz-migration branch May 18, 2026 04:54
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.

1 participant