Prisma v7 – migrate deploy fails in Docker: “The datasource property is required in your Prisma
Hey everyone 👋 I’ve recently upgraded from Prisma v6 → v7, and my Docker deployment started failing with this error:
Error: The datasource property is required in your Prisma config file when using prisma migrate deploy. Prisma schema loaded from prisma/schema.prisma
I’m using the new prisma.config.ts, i usually run my docker using npx prisma migrate deploy && node dist/main.js, but migrate deploy requires datasource url, but v7 doesn't allow datasource url..
Any help would be appreciated 🙏8 Replies
You opted for speed from this bot. Let's conjure up an answer right now!
You’re hitting two overlapping changes:
1. With Prisma Config, the CLI no longer loads env vars for you
When a
In v7-style config, if you use the
When a
prisma.config.ts is present, Prisma skips automatic .env loading – you must load env yourself (for example via dotenv) and/or use env() from prisma/config. [Prisma config env]
2. For the classic engine, datasource is required in prisma.config.tsIn v7-style config, if you use the
classic engine, you must define a datasource object with at least url. [Engine option; Datasource in config]
A minimal prisma.config.ts that should unblock prisma migrate deploy in Docker looks like:
Key points for Docker:
- Ensure DATABASE_URL (and DIRECT_URL if needed, e.g. Supabase) is set in the container’s environment. [Supabase directUrl]
- Since Prisma v7 won’t auto-load .env, your prisma.config.ts (or Docker entrypoint) must load env variables explicitly. [Config/env behavior]
If you’re trying to avoid putting the datasource in prisma.schema, that’s fine: once datasource is set in prisma.config.ts, any datasource in the schema is ignored. [Config datasource override]
🤔 Alright, thanks for letting us know that there's still some help needed. A team member will reply to you shortly.
In the meantime, please let us know any additional info, questions, or which parts of the answer may need clarification.I am having this exact same issue. Came here to make a new discussion about it as well.
@LeSauvage, are you using nextjs? And building it with docker?
I found a solution if so
@LeSauvage Upgrading to Prisma 7 isn't just as simple as just setting the version number and adding the config.
You have to update your Dockerfile as well depending on how you've set it up.
You have to copy the prisma.config.ts into your Docker image.Otherwise, it looks like it's set to default use the
prisma/schema.prisma file. That's because in your Docker image, the prisma.config.ts does not exist.@beanbeanjuice I am using NestJs, should prisma.config.ts be at root level? I currently have it at
./prisma/prisma.config.ts and dockerfile copies the directory so it should not be a problemI'm not sure... I have mine at root level and it works.
I'm not sure if in the specification it lets us put it in the prisma folder
that was the issue; thanks for the hint !
Now i am having it throw an error about not having my database_url in the build... I'll check the doc
You have to set a dummy URL... I'm not sure why but yeah that's what fixes it
Right. makes sense 🙂 it works; I bet theres gonna be issues about this on github
This seems like it might be helpful to our situation too, thanks for bringing this up.
I am not sure I understand why we need to copy the
prisma.config.ts into the docker image, can you elaborate, how you found this?
I am not sure our symptoms are exactly the same, but they might be related. We have a relatively large monorepo, also using nextjs, but the db package is in a standalone package and serves prisma for the entire monorepo.
Our CI is failing with an error
Failed to parse syntax of config file at "/home/runner/work/hamilton/hamilton/packages/db/prisma.config.ts"Which we are not seeing anywhere else 🤔 Did either of you have this symptom too, or was it strictly the datasource missing (I havent seen that one yet, though both issues are config related)? Upon investigating further my issue seemed to be the same. But instead of copying the prisma.config.ts to the docker image (I suspect its already there), I had to - as you suggested - implement a placeholder value for CI to pass, while maintaining a env variable to have it work at runtime. Thanks again! 🙏