Chapter 09 · Prisma Upgrade V7
Subchapter 9.7
references/schema-changes.mdMarkdown4 KBView on GitHub
Prisma v7 promotes prisma-client to the default generator. Update your generator block, output path, and imports accordingly.
This guide is for projects that are actually migrating to Prisma 7. Do not apply these schema changes to MongoDB projects; keep those on Prisma 6.x.
generator client {
provider = "prisma-client"
output = "../generated/prisma"
}Use prisma-client in Prisma v7. The older prisma-client-js generator still exists in the repo for legacy setups, but prisma-client is the default path for current projects.
The output field is mandatory when using prisma-client. Prisma Client no longer generates to node_modules with this generator.
generator client {
provider = "prisma-client"
output = "../generated/prisma"
}Legacy Rust engine settings are gone. With prisma-client, the relevant value is engineType = "client" if you want to state it explicitly, although it is typically inferred and can be omitted.
generator client {
provider = "prisma-client"
output = "../generated/prisma"
engineType = "client"
}If you must stay on CommonJS:
generator client {
provider = "prisma-client"
output = "../generated/prisma"
moduleFormat = "cjs"
}output = "../generated/prisma"Creates files like:
generated/prisma/
client.ts
browser.ts
enums.ts
models.ts
models/output = "../../packages/database/generated/prisma"output = "./generated/prisma"Creates: prisma/generated/prisma/client.ts
The url, directUrl, and shadowDatabaseUrl fields in the datasource block are deprecated in Prisma v7. Move them to prisma.config.ts and keep only the provider in schema.prisma:
datasource db {
provider = "postgresql"
}export default defineConfig({
datasource: {
url: env('DATABASE_URL'),
directUrl: env('DIRECT_URL'),
shadowDatabaseUrl: env('SHADOW_DATABASE_URL'),
},
})Run prisma generate:
npx prisma generateUpdate imports throughout your codebase:
import { PrismaClient } from '../generated/prisma/client'Update .gitignore if you manage this manually:
/generated/prismaReplace Prisma.validator() with TypeScript satisfies when using prisma-client:
import { Prisma } from '../generated/prisma/client'
const userSelect = {
id: true,
email: true,
} satisfies Prisma.UserSelectclient - server-side Prisma Client and Prisma namespacebrowser - browser-safe types and enums without a real PrismaClientenums - slim enum-only entrypointmodels - model types and derived helper typesPreview features still work as before:
generator client {
provider = "prisma-client"
output = "../generated/prisma"
previewFeatures = ["relationJoins", "fullTextSearch"]
}Recent preview-feature examples also include partialIndexes for PostgreSQL, SQLite, SQL Server, and CockroachDB:
generator client {
provider = "prisma-client"
output = "../generated/prisma"
previewFeatures = ["partialIndexes"]
}