fix(migration): rename-admin-email crashes — neon() returns array, not { rows } #24
No reviewers
Labels
No labels
agent-context-drift
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: rstillwell/deckhearth#24
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/migration-neon-return-shape"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Hotfix to
scripts/migrations/2026-05-24-rename-admin-email.js(shipped 2026-05-24 inpick-a-namesquash9abbab6).The migration script crashed on first invocation with:
Root cause
The architect designed the script assuming
@vercel/postgresreturn shape{ rows: [...], rowCount: N }. But the script uses@neondatabase/serverless'sneon()tagged template — which returns the rows array directly.So
const { rows: before } = await sql\...`gavebefore === undefined, and the next line crashed onbefore.length`.The wrapper in
lib/database.jsline 33 explicitly handles this difference (Array.isArray(result) ? result : [result]), but the migration script didn't import the wrapper — it calledneon()directly. This is exactly the kind of cross-contamination AGENTS.md Gotcha #1 warns about ("Two SQL clients live in parallel").Fix
3-line change + 4-line "why" comment:
Applied to all 3 destructuring sites (lines 37, 61, 73 in the original).
Verification (hand-run against prod Neon DB)
No data risk
The original broken script crashed at line 44 — before reaching the
UPDATEstatement at line 54. Prod DB was untouched on the failed first attempt. The hotfix re-run is the first migration the data has seen.PR #21 operator action satisfied
The
pick-a-namePR #21 / squash9abbab6had an unchecked operator-action item ("run the migration script before next admin login"). That is now complete in prod as part of verifying this fix. Admin login usesadmin@deckhearth.comgoing forward.Follow-up surfaced
There's an opportunity for a P3 hygiene convoy:
add-neon-return-shape-rule— write a.cursor/rules/migration-scripts.mdcrule that codifies theneon()vs@vercel/postgresreturn-shape difference as a do-not-repeat. Or fold into the queuedsingle-sql-clientconvoy which would eliminate the dual-client confusion entirely.Test plan
node --checkexit 0admin@deckhearth.com(parent will smoke-test post-merge)Made with Cursor
The latest updates on your projects. Learn more about Vercel for GitHub.
Pipeline Health
Build + CI gates
Build runs on Vercel; this CI runs lint and schema-map drift only (no duplicate build).
Role reports
See individual comments above for details. This rollup updates automatically.