the datasource.url property is required in your prisma config file when using prisma migrate deploy
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 validate prints 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 deploy Expected: All migrations have been successfully applied. or No 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.
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.