← All archived runs
Run: onboarding-blueprint-collection-rename
run.md
Run: onboarding-blueprint-collection-rename
- lane: chore
- branch: claude/onboarding-blueprint-collection-rename-ig7mlh
- pr: #736
lane/output/notes.md
Chore: onboarding-blueprint-collection-rename
- invariant: behaviour unchanged for every persona — the same values are recorded
and rendered on the onboarding launch-complete screen; only the field's name
differs (
collection → collectionName), on the sub-document and in the
client-side mirror that carries it.
- change:
packages/services/src/db/models/onboarding-blueprint.ts:
BlueprintCommitItem.collection → collectionName, in both the type and
BlueprintCommitItemSchema. collection is a reserved Mongoose schema pathname
— it shadows Document.prototype.collection on hydrated documents, so every
server process logged the reserved-pathname warning on first model load
(introduced by PR #674). Renamed rather than suppressed with
suppressReservedKeysWarning: the warning is cosmetic, the shadowing is not.
- change:
packages/services/src/db/services/onboarding-blueprint/commit.ts: the
six committedItems.push({ … }) write sites (products, services, skills,
sla_definitions, tenant_settings, tenants).
- change:
apps/web read path — lib/onboarding/serialize.ts,
components/onboarding/types.ts (SerializedCommitItem, the client-safe
mirror), components/onboarding/launch-complete.tsx (the per-collection counts
on the success screen). COLLECTION_LABELS keys are unchanged: they are Mongo
collection names, and those values did not change.
- change:
packages/services/src/db/migrations/1784300000000-blueprint-commit-item-collection-name.ts
— renames the key inside stored documents. The items are embedded in the
commitRecord sub-document's array, which $rename cannot reach, so each item
is rebuilt via an aggregation-pipeline updateMany + $map. The item shape is a
closed four-field sub-schema (_id: false), so listing the fields explicitly is
lossless and avoids $setField/$unsetField (MongoDB 5.0+, while Mongoose 8
only requires 4.4). Idempotent both ways: the filter matches only documents
carrying the old key and a per-item $cond skips already-renamed items.
- change: prevention rule added to
packages/services/AGENTS.md (new "Schema
field names" section) and to the mongoose-model skill's hard rules — never use
a Mongoose reserved schema pathname as a field name.
- rollback:
pnpm --filter @sustentus/services db:migrate down reverses the data
change exactly (collectionName → collection, same $map shape); revert the
commit to restore the code. Code and migration must move together — a reverted
code deploy against a migrated database (or vice versa) reads the wrong key and
loses the per-collection counts on the success screen, which is why both halves
ship in this one PR.