Skip to content

fix(healthz): schema-qualify SequelizeMeta read — every deploy was reporting migration:null#182

Merged
CryptoJones merged 1 commit into
masterfrom
fix/healthz-migration-schema-qualified
May 19, 2026
Merged

fix(healthz): schema-qualify SequelizeMeta read — every deploy was reporting migration:null#182
CryptoJones merged 1 commit into
masterfrom
fix/healthz-migration-schema-qualified

Conversation

@CryptoJones
Copy link
Copy Markdown
Owner

Closes #181.

Summary

The /healthz migration field has been silently null on every
real deployment of this codebase, despite migrations being cleanly
applied. The controller selected from unqualified "SequelizeMeta"
but sequelize-cli.config.js declares
migrationStorageTableSchema: 'dbo', so the actual table is
dbo.SequelizeMeta. The unqualified read fails with
"relation does not exist" and the catch block maps it to
migration: null — indistinguishable from a legitimate fresh-DB-
pre-migration response.

Schema-qualify the read. Add an integration test pinning the
behavior against the live CI Postgres so a regression of the
qualifier going missing fails CI loudly instead of silently
disabling the field.

Test plan

  • npm run lint clean
  • npm test — 632 passed locally (+1 integration test that skips without DB)
  • CI integration step exercises the new test against real Postgres
  • Existing unit test in tests/api/healthz.test.js still passes

Proudly Made in Nebraska. Go Big Red! 🌽 https://xkcd.com/2347/

…porting migration:null

The /healthz response carries a `migration` field that callers use
to verify a rolling deploy reached the expected schema version
(callout in the controller's JSDoc). On every real deployment of
this codebase, that field has been silently null since the feature
landed.

Root cause: `sequelize-cli.config.js` declares
`migrationStorageTableSchema: 'dbo'` — so migrations record their
applied state in `dbo.SequelizeMeta`, not the default
`public.SequelizeMeta`. But the healthz query selects from an
unqualified `"SequelizeMeta"`, which Postgres resolves against
the search_path (`public` by default). The unqualified read 404s
with "relation does not exist", and the catch block maps it to
`migration: null` without flipping the probe to degraded — exactly
the behavior intended for a fresh pre-migration DB, not for an
operator misconfiguration.

The unit test in `tests/api/healthz.test.js` only asserts the key
exists (null OR string), which is true on the broken read, so the
bug was invisible to CI.

Fix: schema-qualify the read as `"dbo"."SequelizeMeta"`. Add an
integration test in `tests/integration/db-roundtrip.test.js` (auto-
skips without a real DB; runs against the live `postgres:16-alpine`
in CI) that asserts the qualified read returns a real, timestamp-
prefixed migration name. A regression of the qualifier going
missing will fail that test instead of silently disabling the field.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@CryptoJones CryptoJones merged commit 6710b34 into master May 19, 2026
3 checks passed
@CryptoJones CryptoJones deleted the fix/healthz-migration-schema-qualified branch May 19, 2026 09:07
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.

healthz: migration field is always null in production — SequelizeMeta read isn't schema-qualified

1 participant