PrismaP
Prisma4mo ago
6 replies
Gregersen

Seeding not working in prisma.config.ts

Our CLIs have been screaming at us for a while, to upgrade from the package.json "prisma: {}" property, to the
prisma.config.ts
file. With this message:
warn The configuration property `package.json#prisma` is deprecated and will be removed in Prisma 7. Please migrate to a Prisma config file (e.g., `prisma.config.ts`).
For more information, see: https://pris.ly/prisma-config


Currently we have both in our codebase, here's our package.json entry:

  "prisma": {
    "schema": "packages/db/prisma/schema",
    "seed": "pnpm exec tsx packages/seed/src/index.ts"
  },


This works fine. I can run pnpx prisma db seed and it executes this seeding.
However, if I move the seeding to the
prisma.config.ts
, it no longer works. It simply just says "Environment variables loaded from .env" and then immediately exits, as if it found no script.

I should note we are in a monorepo, and this prisma: { ... } block is in the root
package.json
, but the
prisma.config.ts
file is located close to prisma, in the packages/db folder.
I would like to be able to run the pnpx prisma db seed script from root, and have it run the correct seed script, same as I am able to today.
I have also tried various variations of the path in the seed script, to ensure I was pointing to the correct folder. Even if I just print a simple logging script like pnpm why prisma it isn't running.

Is there any reason this couldn't work from the config, when it works from the
prisma
property in
package.json
?
I should note it does work if I first navigate to the db package, and run the prisma db seed script from there, but I'd really avoid having to that, if at all possible.
Was this page helpful?