Skip to content
Nilay Kabariya

Entry No.053·Database··3 min read

Prisma P1012: "url is no longer supported in schema files"

Prisma 7 rejects the url line every older tutorial uses. Reproduced on 7.10.0, plus directUrl, the .env trap and the adapter error that comes next.

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
  1. Step 1: move the URL to prisma.config.ts01
  2. The two errors you get halfway through02
  3. Step 2: the error at runtime03
  4. directUrl and shadowDatabaseUrl04
  5. What didn’t work05
  6. How this was tested06

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@7
import '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 dev and db push with the old url line
  • directUrl alone, then shadowDatabaseUrl alone, 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-pg 7.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

Useful? Pass it on:Post on XFollow @EmotionalMatter

Related entries

  1. No.079

    Prisma P2002 on Prisma 7: e.meta.target is now undefined

    On Prisma 7, P2002 names the constraint on Postgres and e.meta.target is undefined on Postgres and SQLite. Where the field went, and the upsert race.

    > PrismaClientKnownRequestError:

    DATABASE4 min
  2. No.078

    Postgres password authentication failed, but the password is right

    Changed POSTGRES_PASSWORD in docker-compose and the old one still works? The volume keeps it. Five causes of this Postgres error, reproduced with postgres:18.

    > psql: error: connection to server at "localhost" (::1), port 5432 failed: FATAL: password authentication failed for user "postgres"

    DATABASE5 min
  3. No.050

    Prisma P1001: Can't reach database server at localhost:5432

    P1001 prints the same words for five different problems, Docker and Supabase included. Each one reproduced, plus a one-line check that tells them apart.

    > Error: P1001: Can't reach database server at `localhost:5432`

    DATABASE5 min

Post card · Every Sunday

What broke this week.

One email on Sundays: the Node, TypeScript, Python and AI SDK releases that broke builds that week, each one reproduced, with a link to the fix that worked. Never shared, and you can leave any time.

— Nilay

or follow by RSSor on X

By subscribing you agree to the privacy note. One click to leave.

tip: paste the exact error text