MigratorOverview

Migrator

HiveCFM’s legacy predecessor stored surveys in SQL Server. The migrator (packages/migrator/ on a migrator feature branch — it does not exist at origin/development or origin/main, see SQL Cookbook → Not covered here) reads that legacy schema and writes Hive-native Survey, Response, and Contact rows. The result is not always shaped the way a survey built directly in HiveCFM would be.

This page is orientation, not a runbook — what an engineer needs to know about a migrated survey before debugging one, reading its rows, or reviewing a PR that touches migrator code. For the step-by-step operator procedure (preflight, run, finalize-targeting, parity), see the Migration Guide ↗. For the specific “language merges silently skipped” failure mode, see Runbooks → Language merges skipped.

Every figure and behaviour on this page was verified on a real Zain dev migration (2026-09-22). The performance numbers in particular are measured for that one dataset — treat them as a scale reference, not a guarantee for a different survey mix or hardware.

Page layout: one block, or one question per page

The legacy client rendered every voice/IVR, popup, embedded-popup, kiosk, in-chat, WhatsApp, and in-app survey one question at a time, regardless of what its display mode said — the legacy client rewrote them to question-by-question before rendering. The migrator carries that forward unchanged: those channels still migrate as one element per page.

Legacy “classic” WEB surveys are the one exception. If a classic web survey carries skip logic, the legacy client rendered the whole thing as a single page and evaluated jump-to-question rules client-side across that page’s own questions. The migrator reproduces that: a classic web survey with skip logic migrates as one block — one page — whose jump-to-question rules branch only between questions inside that same block. Do not expect one-question-per-page pagination on these; the single-block shape is the migrated survey’s correct, intended shape, not a bug.

If the migrator cannot resolve which legacy channel a survey came from, it refuses rather than guessing:

E-STRUCT-CHANNEL-01

A survey that fails with this code has an ambiguous or missing legacy channel — that is a data problem to resolve at the source, not a migrator flag to override.

Where Survey.type comes from

Survey.type is set from the legacy survey type (CFMSurveyType), not from response or invitation traffic. Legacy web maps to Hive link. A survey that has never received a single response no longer silently defaults to app.

This matters in practice: a survey typed app has no working /s/<id> link page. If a migrated survey looks like it should be link-shareable but its type reads app, that is a legacy-type-provenance question, not a broken share link.

Legacy users are no longer migrated

As of b9b107b77 on origin/AG-migration (deployed), the migrator does not write User or Membership rows by default, for any client — a new customer creates their own accounts in HiveCFM rather than inheriting logins from the legacy system. --migrate-users on run / run-all-departments, and the matching toggle on the TUI run panel, restores the old write-everything behaviour unchanged.

Legacy user rows are still read — the User: N rows telemetry line and its fail-closed read guard are unaffected by this change. The log now states plainly that the rows were read and not migrated, rather than going quiet on users entirely.

Why this is worth knowing rather than assuming “of course it doesn’t migrate users”: the accounts it used to create were unusable logins that existed only to hold a Membership. On the dev target, all 16 migrated users had a synthetic <name>-<legacyId>@<environmentId>.imported.local address, a null password, and zero Account rows — none had ever signed in, and every re-run recreated them from scratch.

⚠️

If you are looking at an environment that was migrated before this change, those synthetic user rows are still there. They are safe to delete only when they carry a legacy_id and their only organization is the one being cleaned up — deleting the User row cascades its Membership. Never delete a user that has no legacy_id: that is a real operator, not a migration artifact. Checking legacy_id works only while a migration program is open; after retirement this column is gone — use the migrate export-provenance artifact instead.

Hidden field rename: DispoCode → InteractionType

Only the name changed — the id in Survey.hiddenFields.fieldIds and the matching key inside Response.data are now InteractionType instead of DispoCode. The source is unchanged: it is still CFMDispCode.DispCode via row.DispCodeID. InteractionType is simply what the legacy product itself calls this concept.

⚠️

This is not the same thing as, and does not touch, Survey.legacy_extras.InteractionType or the CFMDispCodeGroupBrg bridge table that distinguishes Bot from Agent sibling surveys — different derivation, different column, no shared code. The shared word invites exactly that confusion, so treat “the hidden field” and “the Bot/Agent bridge” as two unrelated facts that happen to share a name. Reading Survey.legacy_extras works only while a migration program is open; after retirement this column is gone — use the migrate export-provenance artifact instead.

The rename is not retroactive, and re-running the migration does not fix an already-migrated environment: a re-run declares InteractionType alongside the stale DispoCode, it does not replace it, and it never renames keys on responses that were not themselves re-migrated. An environment migrated under the old id needs an in-place fix — see the Migration Guide ↗ for that repair SQL rather than repeating it here.

One thing not worth chasing on the dev target specifically: both the DispoCode and InteractionType counts were 0 database-wide there before the rename, because that source carries no DispCode values at all. A count of zero on that environment is expected, not a sign the field is broken.

Language consolidation

Sibling surveys that differ only by language are folded into one multi-language survey during migration. A group whose questions don’t line up cleanly across languages is quarantined rather than merged automatically — merging it requires an operator to explicitly approve it:

--approve-quarantine "<fingerprint>"

When one sibling’s language is missing on some survivor question slots, --fold-sibling-question lets an operator say that a named sibling question’s own text supplies the missing language for those slots:

--fold-sibling-question "<fingerprint>:<lang>:<siblingPos>-><survivorPos,...>"
⚠️

This never invents or machine-translates text. A language slot that cannot be filled from an actual sibling question is left disabled and is reported — it is not silently populated with a guess.

Both flags are accepted directly by run and run-all-departments, so an operator-approved fold can happen inside the main migration run instead of needing a second pass. The standalone consolidate-languages command remains the repair path — for example, when a merge was skipped for an unrelated reason (see the stale-client runbook) and needs to be re-applied afterward.

Verifying a migrated survey

A migrated survey’s /s/<id> link cannot be opened anonymously. It answers:

Survey requires identification

Migrated surveys require a personal invitation link — this is expected, not a defect. To verify a migrated survey actually renders and scores correctly:

  • Open it through a real personal invitation link (not the bare /s/<id> URL), or
  • Replay the stored survey row in a local player harness.

A blank “SurveySurveyThe core HiveCFM object. A definition of questions, logic, and targeting — shown to respondents to collect feedback. requires identification” screen from the bare link is not evidence the survey is broken.

Measured performance (one reference run)

Measured on the 2026-09-22 Zain dev migration — 2 departments, --max-workers 4, 1,597,317 responses / 312,156 contacts, target Azure Postgres 17. These are figures for that dataset, not guarantees for a different one.

StageDuration
Whole run-all-departments47m20s
Large department — total43m00s
— Phase 1~1m
— Phase 2~6m
— Phase 3~10m30s
— Phase 4~22m30s
— Phase 5 (parity)~3m
Small department — total~4m
Language consolidation (with fold)19m48s

The 19m48s consolidation run spent nearly all of its time re-pointing 1,257,679 responses belonging to a single merged language pair — consolidation cost scales with responses re-pointed, not with survey or group count. Parity for the run came back 23 pass / 2 warn / 0 fail.

See also

  • Migration Guide ↗ — the full operator runbook: preflight, run, finalize-targeting, audiences, Hub backfill, parity.
  • Runbooks → Language merges skipped — the specific failure where consolidation silently no-ops.
  • SQL Cookbook — recipes against the Hive-native schema; explicitly does not cover the migrator’s legacy-side columns.

HiveCFM Developer Hub — internal team guide