skip to content

Prisma

Node's schema-driven ORM: you declare models in a .prisma file and get a fully typed client, migrations, and relation queries generated from it. Interviewers ask about Prisma because the generated client, the migration workflow, and its connection behaviour on serverless platforms are exactly where teams get burned.

on this pageshow

explore

questions

page 2 of 2

In Prisma 7, concurrent checkouts oversell a product's stock; which Prisma Client tools prevent it, and when do you need a Serializable $transaction with P2034 retries?

level: seniorimportance: should knowfreq 38%

basics

~20 s

Put the check in the write: updateMany filtering stock gte the quantity with a decrement, where count 0 means sold out, or a version field in where. Reserve a Serializable $transaction, retried on P2034, for invariants spanning reads.

open as a page

Under load, a Prisma 7 checkout's interactive transactions fail with P2028 errors; what do maxWait and timeout govern, and how do you fix the checkout?

level: seniorimportance: should knowfreq 40%

basics

~20 s

maxWait (default 2000 ms) bounds the wait to start the transaction, which needs a pooled connection; timeout (default 5000 ms) bounds its run before Prisma rolls it back. Long callbacks hold connections, so the fix is shorter callbacks, not bigger numbers.

open as a page

Would you set client-wide transactionOptions in a Prisma 7 service on PostgreSQL, such as Serializable isolation or longer timeouts, or keep the defaults and opt in per transaction?

level: principalimportance: should knowfreq 32%

basics

~20 s

Usually keep the defaults (database isolation, maxWait 2000 ms, timeout 5000 ms) and opt into Serializable per transaction through one retry helper. Client-wide Serializable makes every transaction need P2034 retries; a longer global timeout lets slow transactions hold pool connections.

open as a page

In Prisma 7, how do you adopt Prisma Migrate on an existing production database without recreating its tables or losing data?

level: seniorimportance: nice to knowfreq 28%

basics

~20 s

Baseline it: introspect with prisma db pull, write an initial migration with prisma migrate diff from empty to the schema, then mark it applied on each existing database with prisma migrate resolve --applied so deploy never runs it there.

open as a page

Would you run a Prisma 7 schema with relationMode = "prisma" instead of database foreign keys, and what does the team give up if it does?

level: principalimportance: nice to knowfreq 28%

basics

~20 s

Keep the default foreignKeys mode wherever the database allows foreign keys, since it checks every writer. Use relationMode = "prisma" only when it does not, accepting that only Prisma Client is checked, creates go unchecked and you add the indexes.

open as a page

showing 31–35 of 35