loading entry…
loading entry…
db.transaction(async (tx) => { ... }) on a connection created via drizzle({ schema, ... }) over the neon-http driver throws NeonDbError: ... at runtime. Test mocks may pass; production fails.
The neon-http driver is request-scoped (one HTTP round-trip per query); transactions require a stateful TCP connection. The driver does not support BEGIN/COMMIT sequencing.
Use db.batch([...statements]) to atomically commit a fixed list of statements in one round-trip:
await db.batch([
db.insert(schema.projects).values({ ... }),
db.insert(schema.transitions).values({ ... }),
]);
If you need a dependent ID across statements, pre-generate UUIDs in application code rather than relying on RETURNING from the first statement.
~/.claude/playbooks/drizzle-orm.md