title: Prisma - Postgres transaction - problem read incremental number in concurrent transaction
body: <p>I am currently trying to use the new &quot;interactiveTransactions&quot; preview feature of Prisma. However, it does not seem to actually make my database changes as a transaction.</p>
  <p>I am trying to update an incremental number on my school table whenever I create a new report.</p>
  <p>This is how my tables look like:</p>
  <pre><code>model Report {
    id   String @id @default(cuid())
    name String
    publicId Int 
    schoolId String
  
    school @relation(fields: [schoolId], references: [id])
    @@unique([publicId, schoolId])
  }
  
  model School {
    id   String @id @default(cuid())
    name String
    incrementalReportNumber Int @default(1001)
  
    reports         Report[]
  }
  </code></pre>
  <p>my code to increment the number whenever I am creating a new report looks like this:</p>
  <pre><code> report = await prisma.$transaction(async () =&gt; {
        // get current report number
        const school = await prisma.school.findUnique({
          where: {
            id: school.id
          }
        });
        const newIncrementalReportNumber = school.incrementalReportNumber + 1;
  
        // Increase incrementalReportNumber
        await prisma.school.update({
          where: { id: school.id },
          data: {
            incrementalReportNumber: newIncrementalReportNumber
          }
        });
  
        // Create report
        const newReport = await prisma.report.create({
          data: {
            publicId: newIncrementalReportNumber,
            name: 'new report'
          },
        });
  
        // Return
        return newReport;
      });
  </code></pre>
  <p>When I create multiple reports at the same time I get an &quot;Unique constraint failed&quot; error,</p>
  <pre><code>the Error PrismaClientKnownRequestError: Unique constraint failed on the fields: (`publicId`,`schoolId`)
  </code></pre>
  <p>because when I get <em>incrementalReportNumber</em>, some process have same value, despite other process already increment it.</p>
  <p>I registered the &quot;interactiveTransactions&quot; preview feature with prisma like this:</p>
  <pre><code>datasource db {
    provider = &quot;postgresql&quot;
    url      = env(&quot;DATABASE_URL&quot;)
  }
  
  generator client {
    provider        = &quot;prisma-client-js&quot;
    previewFeatures = [&quot;interactiveTransactions&quot;]
  }
  </code></pre>
  <p>I am using Prisma version &quot;3.2.1&quot;</p>