PrismaP
Prisma6mo ago
2 replies
.jsonp

When to run migration in production with Turborepo?

Hey there 👋 in the official Prisma-Turborepo guide (https://www.prisma.io/docs/guides/turborepo#1-create-your-monorepo-using-turborepo), it says to "ensure that db:generate is always executed before running dev or build. Additionally, make sure both db:deploy and db:generate are executed before db:build." Yet, in the example code given, we see only db:generate as a dependency of build.

{
  "$schema": "https://turbo.build/schema.json",
  "ui": "tui",
  "tasks": {
    "build": {
      "dependsOn": ["^build", "^db:generate"],
      "inputs": ["$TURBO_DEFAULT$", ".env*"],
      "outputs": [".next/**", "!.next/cache/**"],
      "env": ["DATABASE_URL"]
    },
    // ... 
}


If db:deploy (prisma migrate deploy) needs to run prior to the build command, do we run this explicitly with Turbo (specified in the config)?
"build": {
   "dependsOn": ["^build", "^db:generate", "^db:deploy"],
      // ...

...or do we run this independently using our build environment like turbo db:deploy && turbo build --filter=api? Also, I am assuming the deploy script always go before the generate script, but I am unsure how to order these in the execution chain, or if that's even possible. I believe these scripts might execute simultaneously?
Was this page helpful?