loading entry…
loading entry…
You need to atomically insert a parent row and one or more child rows that reference it. With drizzle-orm/neon-http, you cannot use db.transaction; you must use db.batch([...]) which queues statements upfront.
Generate the parent UUID in application code so the child rows can reference it before the batch executes:
import { randomUUID } from 'node:crypto';
const projectId = randomUUID();
await db.batch([
db.insert(schema.projects).values({ id: projectId, name: '...' }),
db.insert(schema.transitions).values({
id: randomUUID(),
projectId,
fromState: 'inbox',
toState: 'triage',
}),
]);
db.batch returns one result per statement; index into the array if you need the inserted rows.blockers/neon-http-transaction-trap~/.claude/playbooks/drizzle-orm.md