Solution skill
the datasource.url property is required in your prisma config file when using prisma migrate deploy
Complete solution
Fixes the Prisma 7 error 'the datasource.url property is required in your prisma config file when using prisma migrate deploy' by adding a datasource url entry to prisma.config.ts at the project root and copying that file into Docker images. Use when the migrate deploy CLI fails with this exact message on Prisma 7. Not for Prisma 6 or earlier, and not for missing DATABASE_URL environment variable errors.
TL;DR: Add a datasource url entry to prisma.config.ts at your project root, pointed at your real database URL, then re-run npx prisma migrate deploy. If you deploy with Docker, copy prisma.config.ts into the image too. This happens because Prisma 7 moved the CLI connection string out of schema.prisma into the config file, so the migrate CLI refuses to run without it.
Error: the datasource.url property is required in your prisma config file when using prisma migrate deploySteps
Create
prisma.config.tsat the project root (not inside the prisma folder):import { defineConfig, env } from 'prisma/config' import 'dotenv/config' export default defineConfig({ schema: 'prisma/schema.prisma', datasource: { url: env('DATABASE_URL') }, })Expected:
npx prisma validateprints that the schema is valid and that it loaded the Prisma config.Docker users: copy the config file into the image next to the prisma folder:
COPY prisma.config.ts ./ COPY prisma ./prismaExpected: the deploy container finds the config; the error disappears from the container logs.
Re-run the deploy:
npx prisma migrate deployExpected:
All migrations have been successfully applied.orNo pending migrations to apply.
When to use
- You hit this exact error on
prisma migrate deploy,migrate dev, ordb pushwith Prisma 7 or later - You upgraded from Prisma 5/6 and removed
urlfrom the datasource block
When not to use
- Prisma 6 or earlier: there the URL still lives in
schema.prismaand this error does not exist - The failure is
Environment variable not found: DATABASE_URLinstead: that is a different fix (the env var itself is missing)
Compatibility
Prisma 7.x CLI. Node 18+. Applies to migrate deploy, migrate dev, and db push.
Variant phrasing: same error on db push
db push reads the same config file, so the fix is identical.
Why it happens
Prisma 7 rejects url inside the datasource block of schema.prisma and expects the CLI connection string in prisma.config.ts instead. As a side effect, once the config file exists the CLI stops auto-loading .env on its own, which is why the config needs the dotenv/config import to keep working locally.
Edge cases
- Wrong location: Prisma looks for
prisma.config.tsat the project root (and parent dirs), notprisma/config.ts. env()comes fromprisma/config;process.env.DATABASE_URLworks too, butenv()is the documented form.- If you see
Prisma config detected, skipping environment variable loading, that is expected Prisma 7 behavior, not an error.
Evidence
A deploy script failed at the Prisma migration step with the error 'The datasource.url property is required in your Prisma config file when using prisma migrate deploy.' even though DATABASE_URL was set. The root cause: on Prisma 7 the datasource url no longer lives in schema.prisma, so migrate deploy demands it in prisma.config.ts. The reporter fixed it by creating prisma.config.ts at the project root with a datasource url forwarded from the environment, and by copying prisma.config.ts into the production Docker image next to the prisma folder. After that, prisma migrate deploy ran cleanly. Source: https://github.com/rendyuwu/markview/issues/1
By @issueatlas · Version 1 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_moDVuxzKdxaKnU8Y5WvILQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">the datasource.url property is required in your prisma config file when using prisma migrate deploy <span>— Vectle</span></a>