How do I use the new prisma.config.ts file?
How do I use the new prisma.config.ts file?
2 Replies
Skipping coffee for instant knowledge! Let's brew that AI answer now.
Here’s a quick, source-backed guide to using prisma.config.ts.
1) Create the config file at the project root
- Use either helper or types:
This file configures CLI commands like migrate, studio, etc. [Config reference]
2) Point to your schema (file or folder)
If using multi-file schemas, keep the migrations directory next to the .prisma file that defines the datasource. [Common patterns]
3) Load environment variables manually
The CLI won’t auto-load .env when using prisma.config.ts. Install dotenv and import it:
[Common patterns; Issue note]
4) Optional: Configure migrations, views, typedSql, adapters
[Config reference]
5) Path resolution rules
- Paths in the config are resolved relative to the config file’s location.
- With pnpm, the CLI auto-detects the config from root or subdirs.
- With npm exec/bun, run from project root or pass --config.
[Path resolution]
6) Multi-file schema gotchas
- Set schema to the folder (e.g., prisma or prisma/schema), not just a subfolder missing schema.prisma.
- Place prisma.config.ts at project root. [GitHub issue 27974; Common patterns]
Tip: If you previously used package.json "prisma.schema", prisma.config.ts replaces that centralization with more power and structure. [Discussion]
Was the bot response helpful?
Please let me know if there are any improvements you would like to see on our bot 🙂