fix(healthz): schema-qualify SequelizeMeta read — every deploy was reporting migration:null#182
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #181.
Summary
The
/healthzmigrationfield has been silently null on everyreal deployment of this codebase, despite migrations being cleanly
applied. The controller selected from unqualified
"SequelizeMeta"but
sequelize-cli.config.jsdeclaresmigrationStorageTableSchema: 'dbo', so the actual table isdbo.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 lintcleannpm test— 632 passed locally (+1 integration test that skips without DB)tests/api/healthz.test.jsstill passesProudly Made in Nebraska. Go Big Red! 🌽 https://xkcd.com/2347/