Language merges all skipped after a schema update
Applies to: migrator
For background on how migrated surveys and language consolidation work in general, see Migrator.
Symptom
A migration run completes, parity passes, and nothing in the top-level exit code says anything is wrong — but the consolidation summary line reads:
Language consolidation APPLIED: 0 merged 0 responses re-pointedand the log carries one warning per language group, naming the survivor and a Zod validation failure on a column that plainly exists in the schema:
merge skipped for survivor <id>: [{"code":"invalid_type","expected":"number","received":"undefined","path":["showSurveyEveryDays"]}]A migration that “succeeded” can still have silently skipped every language merge. The exit code and the parity report do not catch this — the only place it shows up is that one summary line. Always read it.
Likely cause
The machine running the migrator has a generated PrismaPrismaThe TypeScript ORM HiveCFM uses to talk to Postgres. The schema lives at packages/database/schema.prisma. client that is
older than packages/database/schema.prisma. prisma.survey.findUnique
then returns the survivor row without the newer column, and the survey shape
gate (ZSurvey) requires that key to be present — even though it is
nullable — so every assembled survey object fails validation and the merge
for that group is skipped rather than applied.
This happens whenever code is updated on a migration host (patch, git pull,
branch switch) without also regenerating the PrismaPrismaThe TypeScript ORM HiveCFM uses to talk to Postgres. The schema lives at packages/database/schema.prisma. client. The field name in
the message will differ as the schema grows over time — what identifies this
failure class is the shape: "expected X, received undefined" on a column
that is present in schema.prisma but produces a validation error anyway.
Diagnosis
Confirm the generated client is behind schema.prisma
grep -c showSurveyEveryDays packages/database/schema.prisma
grep -c showSurveyEveryDays node_modules/.prisma/client/schema.prismaIf the second command returns 0 while the first returns 1 or more, the
generated client predates the schema change. Check the file date too — the
generated copy will be visibly older than your last schema edit:
ls -l packages/database/schema.prisma node_modules/.prisma/client/schema.prismaFix
Regenerate the Prisma client and rebuild the migrator
pnpm --filter @hivecfm/database generate
pnpm build # run inside packages/migratorConfirm the column now appears in the generated schema
grep -c showSurveyEveryDays node_modules/.prisma/client/schema.prisma
# expect 1 or more — not 0Re-run the consolidation step
Re-run with the same approvals as the original attempt — a stale client does not change which merges an operator already approved:
node dist/cli.js consolidate-languages --client <envId> --config <envfile> --apply \
--approve-quarantine "<fingerprint>" \
--fold-sibling-question "<fingerprint>:<lang>:<siblingPos>-><survivorPos,...>"Verify
- The consolidation summary line now reports a non-zero merge count, e.g.
Language consolidation APPLIED: N merged M responses re-pointed. - No
merge skipped for survivor <id>warnings remain in the log for groups that were expected to fold. grep -c <column> node_modules/.prisma/client/schema.prismamatchesgrep -c <column> packages/database/schema.prismafor the column named in the original warning.
Prevent
- After any code or schema update on a migration host — a patch, a
git pull, a branch switch — regenerate the Prisma client and rebuild before running anything:pnpm --filter @hivecfm/database generate && pnpm build. - Do not trust a green exit code alone. Read the consolidation summary line every time;
0 mergedon a run that was expected to fold languages is a defect, not a no-op. - If you scripted or automated a migration run, have it grep the summary line for a non-zero merge count (when merges were expected) and fail loudly if it reads
0 merged.
Verified on a real Zain dev migration (2026-09-22): this silently invalidated a 43-minute production-sized run before it was caught by reading the summary line.