Skip to content

Commit a98aff2

Browse files
authored
fix(internals): improve missing model message to hint about --require-models flag (prisma#29319)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## 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. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 3f2438c commit a98aff2

2 files changed

Lines changed: 25 additions & 5 deletions

File tree

packages/internals/src/__tests__/getGenerators/getGenerators.test.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,12 @@ describe('getGenerators', () => {
658658
expect(stripVTControlCharacters(e.message)).toMatchInlineSnapshot(`
659659
"
660660
You don't have any models defined in your schema.prisma, so nothing will be generated.
661-
You can define a model like this:
661+
662+
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:
663+
664+
$ prisma generate
665+
666+
Otherwise, you can define a model like this:
662667
663668
model User {
664669
id Int @id @default(autoincrement())
@@ -694,7 +699,12 @@ describe('getGenerators', () => {
694699
expect(stripVTControlCharacters(e.message)).toMatchInlineSnapshot(`
695700
"
696701
You don't have any models defined in your schema.prisma, so nothing will be generated.
697-
You can define a model like this:
702+
703+
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:
704+
705+
$ prisma generate
706+
707+
Otherwise, you can define a model like this:
698708
699709
model User {
700710
id String @id @default(auto()) @map("_id") @db.ObjectId

packages/internals/src/utils/missingGeneratorMessage.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { blue, bold } from 'kleur/colors'
1+
import { blue, bold, dim } from 'kleur/colors'
22

33
import { highlightDatamodel } from '../highlight/highlight'
44
import { link } from './link'
@@ -22,7 +22,12 @@ ${link('https://pris.ly/d/prisma-schema')}
2222
export const missingModelMessage = `\nYou don't have any ${bold('models')} defined in your ${bold(
2323
'schema.prisma',
2424
)}, so nothing will be generated.
25-
You can define a model like this:
25+
26+
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:
27+
28+
${dim('$')} prisma generate
29+
30+
Otherwise, you can define a model like this:
2631
2732
${bold(
2833
highlightDatamodel(`model User {
@@ -39,7 +44,12 @@ ${link('https://pris.ly/d/prisma-schema')}
3944
export const missingModelMessageMongoDB = `\nYou don't have any ${bold('models')} defined in your ${bold(
4045
'schema.prisma',
4146
)}, so nothing will be generated.
42-
You can define a model like this:
47+
48+
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:
49+
50+
${dim('$')} prisma generate
51+
52+
Otherwise, you can define a model like this:
4353
4454
${bold(
4555
highlightDatamodel(`model User {

0 commit comments

Comments
 (0)