From a98aff2ede1598a7718f07cde9204b435ae4b5b4 Mon Sep 17 00:00:00 2001 From: Abdur Rehman Khalid <40769860+AbdurRKhalid@users.noreply.github.com> Date: Tue, 17 Mar 2026 12:46:41 +0100 Subject: [PATCH] fix(internals): improve missing model message to hint about --require-models flag (#29319) ## Summary by CodeRabbit * **Documentation** * Expanded user-facing guidance when no models are detected: clearer instructions about generating Prisma Client, an example generate command, and advice for using raw SQL queries without model requirements. * **Tests** * Updated test snapshots to reflect the expanded guidance in informational messages. --- .../getGenerators/getGenerators.test.ts | 14 ++++++++++++-- .../src/utils/missingGeneratorMessage.ts | 16 +++++++++++++--- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/packages/internals/src/__tests__/getGenerators/getGenerators.test.ts b/packages/internals/src/__tests__/getGenerators/getGenerators.test.ts index f797131d35e3..c17736361058 100644 --- a/packages/internals/src/__tests__/getGenerators/getGenerators.test.ts +++ b/packages/internals/src/__tests__/getGenerators/getGenerators.test.ts @@ -658,7 +658,12 @@ describe('getGenerators', () => { expect(stripVTControlCharacters(e.message)).toMatchInlineSnapshot(` " You don't have any models defined in your schema.prisma, so nothing will be generated. - You can define a model like this: + + Prisma Client is typically generated from models defined in your schema. If you plan to use raw SQL queries only (e.g. $queryRaw), remove the --require-models flag to generate the client without models: + + $ prisma generate + + Otherwise, you can define a model like this: model User { id Int @id @default(autoincrement()) @@ -694,7 +699,12 @@ describe('getGenerators', () => { expect(stripVTControlCharacters(e.message)).toMatchInlineSnapshot(` " You don't have any models defined in your schema.prisma, so nothing will be generated. - You can define a model like this: + + Prisma Client is typically generated from models defined in your schema. If you plan to use raw queries only, remove the --require-models flag to generate the client without models: + + $ prisma generate + + Otherwise, you can define a model like this: model User { id String @id @default(auto()) @map("_id") @db.ObjectId diff --git a/packages/internals/src/utils/missingGeneratorMessage.ts b/packages/internals/src/utils/missingGeneratorMessage.ts index 35caa7d75fb4..f0d89108c170 100644 --- a/packages/internals/src/utils/missingGeneratorMessage.ts +++ b/packages/internals/src/utils/missingGeneratorMessage.ts @@ -1,4 +1,4 @@ -import { blue, bold } from 'kleur/colors' +import { blue, bold, dim } from 'kleur/colors' import { highlightDatamodel } from '../highlight/highlight' import { link } from './link' @@ -22,7 +22,12 @@ ${link('https://pris.ly/d/prisma-schema')} export const missingModelMessage = `\nYou don't have any ${bold('models')} defined in your ${bold( 'schema.prisma', )}, so nothing will be generated. -You can define a model like this: + +Prisma Client is typically generated from models defined in your schema. If you plan to use raw SQL queries only (e.g. ${bold('$queryRaw')}), remove the ${bold('--require-models')} flag to generate the client without models: + + ${dim('$')} prisma generate + +Otherwise, you can define a model like this: ${bold( highlightDatamodel(`model User { @@ -39,7 +44,12 @@ ${link('https://pris.ly/d/prisma-schema')} export const missingModelMessageMongoDB = `\nYou don't have any ${bold('models')} defined in your ${bold( 'schema.prisma', )}, so nothing will be generated. -You can define a model like this: + +Prisma Client is typically generated from models defined in your schema. If you plan to use raw queries only, remove the ${bold('--require-models')} flag to generate the client without models: + + ${dim('$')} prisma generate + +Otherwise, you can define a model like this: ${bold( highlightDatamodel(`model User {