The error, verbatim
Jump to the fix ↓Error: Prisma schema validation - (get-config wasm)
Error code: P1012
error: The datasource property `url` is no longer supported in schema files. Move connection URLs for Migrate to `prisma.config.ts` and pass either `adapter` for a direct database connection or `accelerateUrl` for Accelerate to the `PrismaClient` constructor.
--> prisma\schema.prisma:8
|
7 | provider = "postgresql"
8 | url = env("DATABASE_URL")
Tested on
- prisma / @prisma/client
- 7.10.0
- @prisma/adapter-pg
- 7.10.0
- Postgres
- 17 (Docker)
- Node / OS
- 24.14.0 / Windows 11 Pro
✓ Re-verified on prisma (7.x) 7.10.1 (Linux): 6/6 checks still hold · results
Contents
Every Prisma tutorial written before Prisma 7, and most starter templates, put the connection string in the schema:
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
Prisma 7 refuses that line. On 7.10.0, every command that reads the schema stopped at it with error P1012, before touching the database: prisma generate, prisma validate, prisma migrate dev and prisma db push all printed the error above.
Fixing it takes three changes, and each half-done version fails with a different, less obvious error. I reproduced all of them below, in the order you’ll meet them.
If you installed Prisma in the last few weeks and got JSON errors like No command registered for generate instead, you’re on the Prisma 8 release candidate, not Prisma 7. That’s a different problem.
Step 1: move the URL to prisma.config.ts
Delete the url line from the datasource block. Keep provider:
datasource db {
provider = "postgresql"
}Then create prisma.config.ts next to package.json:
import 'dotenv/config';
import { defineConfig, env } from 'prisma/config';
export default defineConfig({
schema: 'prisma/schema.prisma',
migrations: { path: 'prisma/migrations' },
datasource: { url: env('DATABASE_URL') },
});The first line matters: Prisma 7 doesn’t load your .env file by itself any more, so install dotenv if you don’t have it (npm i dotenv).
Leaving the url line in place and adding the config file next to it doesn’t work: Prisma 7.10.0 still stopped at the schema with the same P1012.
The two errors you get halfway through
Removed the line, didn’t create the config. This one is misleading because prisma generate succeeds (it doesn’t need a database). The next migration fails:
$ npx prisma migrate dev --name init
Error: The datasource.url property is required in your Prisma config file when using prisma migrate dev.
Created the config, without import 'dotenv/config'. The .env file is right there, and Prisma still can’t see the variable:
Failed to load config file "D:\nk-repro\prisma-p1012" as a TypeScript/JavaScript module.
Error: PrismaConfigEnvError: Cannot resolve environment variable: DATABASE_URL.
Older Prisma versions read .env themselves, which is why this catches people out. Both errors go away with the config from step 1.
Step 2: the error at runtime
Once the CLI works, the app is next. The schema no longer tells Prisma Client where the database is, so new PrismaClient() with no arguments fails as soon as it’s created:
PrismaClientInitializationError: PrismaClient was instantiated without any options. A driver adapter is required to connect to your database.
Pass a driver adapter. For Postgres that’s @prisma/adapter-pg, on the same version as your client:
npm i @prisma/adapter-pg@7import 'dotenv/config';
import { PrismaPg } from '@prisma/adapter-pg';
import { PrismaClient } from './generated/prisma/client';
const prisma = new PrismaClient({
adapter: new PrismaPg({ connectionString: process.env.DATABASE_URL }),
});The import path is the output folder from your generator block (Prisma 7’s prisma-client generator writes the client into your project), followed by /client.
directUrl and shadowDatabaseUrl
If you use a connection pooler (Supabase, Neon, PgBouncer), your schema probably also has directUrl. With the url line gone, that’s the next P1012:
error: The datasource property `directUrl` is no longer supported in schema files. Move connection URLs to `prisma.config.ts`.
shadowDatabaseUrl gets the same message with its own name. But “move it to prisma.config.ts” only half works for directUrl, because Prisma 7’s config has no directUrl setting: its type definition only has url and shadowDatabaseUrl. The split works differently now: Migrate uses the URL in the config, and the app uses whatever you give the adapter.
Put the direct URL in the config, for migrations:
datasource: {
url: env('DIRECT_URL'),
// shadowDatabaseUrl: env('SHADOW_DATABASE_URL'), if you used one
},And give the pooled URL to the adapter, for the app:
new PrismaPg({ connectionString: process.env.DATABASE_URL })What didn’t work
How this was tested
A fresh npm project on Windows 11 with Node 24.14.0, prisma and @prisma/client 7.10.0 (installed as prisma@7, because latest is currently the Prisma 8 release candidate), and Postgres 17 in Docker. In order:
- each of
generate,validate,migrate devanddb pushwith the oldurlline directUrlalone, thenshadowDatabaseUrlalone, with and without a config file- the line removed with no config
- a config without
dotenv - the full fix with
migrate dev new PrismaClient()with no options, then with@prisma/adapter-pg7.10.0- the direct/pooled split with one URL deliberately broken
Every message above is copied from those runs on October 9, 2026.
The code is public, so you can run it yourself: prisma-p1012 in nk-repro.
— N.K., end of entry No.053