P
Prisma2w ago
PB

The datasource property `directUrl` is no longer supported in schema files. Move connection URLs to

I just got this typescript error on datasource db { provider = "postgresql" url = env("DATABASE_URL") directUrl = env("DIRECT_URL") }
6 Replies
Prisma AI Help
You selected the bot's instantaneous insights. Let me compile your answer right away! That error message is misleading: datasource.directUrl is still supported in current Prisma versions. The official docs and multiple guides actively show and recommend directUrl for setups that use connection poolers, including: - General connection poolers / PgBouncer [External poolers] - Supabase [Supabase docs] - Neon [Neon docs] - Prisma Accelerate [Accelerate getting started] - Schema reference for datasource [Schema datasource; directUrl option] A valid schema is for example:
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
directUrl = env("DIRECT_URL")
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
directUrl = env("DIRECT_URL")
}
If you see "directUrl is no longer supported" it likely comes from: - A tool or plugin (e.g. an IDE extension or linter) that’s out of date or not using the correct Prisma version. - A TypeScript type or custom code around Prisma that doesn’t know about directUrl. What to do: 1. Ensure you’re using a Prisma version that supports directUrl (>= 4.10.0). [directUrl discussion] 2. Update your editor/Prisma VS Code extension and restart the TypeScript server. 3. Run npx prisma validate – if it passes, your schema is valid and the TS/IDE error is coming from tooling, not Prisma itself. If npx prisma validate fails, please share that exact error.
Nurul
Nurul2w ago
Once you have upgraded to Prisma 7, url and directUrl would no longer be a valid attribute in datasource block of schema.prisma The value of DIRECT_URL should go in the url value in datasource block of prisma.config.ts and the value of DATABASE_URL should be passed to adapter while initialising Prisma Client
Brokenwind
Brokenwind2w ago
Why couldn't the npx prisma match the version we are using? We are forced to update because of this mess.
prisma.config.ts
import "dotenv/config";
import path from "node:path";
import { env, defineConfig } from "prisma/config";

export default defineConfig({
datasource: { url: env("DATABASE_URL") },

schema: path.join("src", "prisma"),

typedSql: {
path: path.join("src", "prisma", "sql"),
},
});
prisma.config.ts
import "dotenv/config";
import path from "node:path";
import { env, defineConfig } from "prisma/config";

export default defineConfig({
datasource: { url: env("DATABASE_URL") },

schema: path.join("src", "prisma"),

typedSql: {
path: path.join("src", "prisma", "sql"),
},
});
schema.prisma
datasource db {
provider = "postgresql"
}
schema.prisma
datasource db {
provider = "postgresql"
}
And I still get Error: The datasource property is required in your Prisma config file when using prisma generate --sql
Gregersen
Gregersen2w ago
npx always works by fetching the newest version of whatever tool you are trying to run. You could setup something that works via a script in your package json and running it via npm, that will use your installed version instead. Alternatively you can specifiy the same version as you use locally, with npx, ie. npx prisma@6.13 ...
Brokenwind
Brokenwind2w ago
Should've been automatic and checks the package.json if you ask me. v7 is one hell of a breaking change. Enums are a nightmare to work with. I'm reverting to v6.
Gregersen
Gregersen2w ago
Hehe perhaps. I've certainly found myself confused about that behaviour before. But that's an issue you'll have to take up with the team behind npm as that behaviour was always like this 😄 There are certainly breaking changes in v7, but they have been incrementally added in version 6.x, to smoothen the ride, but yeah if you jump directly I imagine there'd be a lot of issues. I'm quite enjoying the tightening of enums, it matches better with how I'd expect them to work in Typescript. What issues are you having that makes them a nightmare to work with?

Did you find this page helpful?