You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add ability to configure custom schema location instead of requiring --schema arg #3144
For people who use a custom schema location, the current DX is super painful. All of the CLI commands fail unless you explicitly pass --schema. When you are using the cli a lot in a project with a custom schema, this gets super annoying having to type --schema all the time.
Additionally, using a custom schema means the prisma postinstall hook fails, requiring projects to add their own postinstall hook to manually generate the client.
And then also of course we use a custom schema location in Blitz and abstract most of the prisma CLI commands. But when a user needs to drop down a level and use the prisma cli directly, they often get stuck because they don't know they need to provide --schema
Suggested solution
I want to be able to define prisma config in the package.json file. Something like this:
I agree that having a way to change the expected standard schema path is useful, vs. having to supply the --schema for each command execution. Even though if your framework (like Blitz) uses that internally, it makes your experience a lot worse if you ever want to use prisma directly as you probably do not know about this requirement.
Not sure about the suggested solution though - maybe there are other alternatives.
Thanks @flybayer for raising this! I totally agree that this makes things quite cumbersome to use.
Before diving into solutions, I would like to understand your situation a bit better.
What is the reasoning for having the schema in a custom location?
It looks like you have it in a folder called db instead of prisma.
An option would also be to add db to the "watch list" where we check for the file.
The reason I don't want to immediately jump into discussing custom solutions: The solutions introduce new challenges.
Let's say we introduce a section in the package.json to configure the schema location.
What about the Prisma Go Client? Should it also have a custom location configured? Should go users have a package.json? The Go Client is not part of the official offering yet, but we will have multiple languages at some point. The design of this needs to take that into account.
To get something language agnostic, one could think of a dot file. Like .prismarc. That would however introduce more dotfiles to your project root, which can already be quite full sometimes. What would the purpose of the dot file be? As of now just to point to the schema.prisma.
So no matter which solution we will choose, there will be trade-offs.
That means that even if you have a path defined in your package.json, you can manually override that by using --schema in the CLI command.
Additionally the output the CLI gives you where it loaded the .env file from (which is next to the schema file) should also mention the schema.prisma file to make that explicit.
Details about documentation of this feature are still figured out, as the schema loading is currently not documented at all directly.
I like that package.json was used, I wish more libraries would standardize around it instead of polluting the project root with tons of independent config files
edit: spoke too soon
warn The configuration property `package.json#prisma` is deprecated and will be removed in Prisma 7. Please migrate to a Prisma config file (e.g., `prisma.config.ts`).
For more information, see: https://pris.ly/prisma-config
Activity
janpio commentedon Jul 27, 2020
I agree that having a way to change the expected standard schema path is useful, vs. having to supply the
--schemafor each command execution. Even though if your framework (like Blitz) uses that internally, it makes your experience a lot worse if you ever want to useprismadirectly as you probably do not know about this requirement.Not sure about the suggested solution though - maybe there are other alternatives.
timsuchanek commentedon Aug 6, 2020
Thanks @flybayer for raising this! I totally agree that this makes things quite cumbersome to use.
Before diving into solutions, I would like to understand your situation a bit better.
What is the reasoning for having the schema in a custom location?
It looks like you have it in a folder called
dbinstead of prisma.An option would also be to add
dbto the "watch list" where we check for the file.timsuchanek commentedon Aug 6, 2020
The reason I don't want to immediately jump into discussing custom solutions: The solutions introduce new challenges.
Let's say we introduce a section in the
package.jsonto configure the schema location.What about the Prisma Go Client? Should it also have a custom location configured? Should go users have a package.json? The Go Client is not part of the official offering yet, but we will have multiple languages at some point. The design of this needs to take that into account.
To get something language agnostic, one could think of a dot file. Like
.prismarc. That would however introduce more dotfiles to your project root, which can already be quite full sometimes. What would the purpose of the dot file be? As of now just to point to the schema.prisma.So no matter which solution we will choose, there will be trade-offs.
21 remaining items
janpio commentedon Sep 8, 2020
Some technical details for the implementation after discussion with @timsuchanek and @Jolg42:
--schemaor 2) fall back to./prisma/schema.prisma(or./schema.prisma) to find the schema file to load.package.jsonfile as defined in Add ability to configure custom schema location instead of requiring--schemaarg #3144 (comment).package.json, you can manually override that by using--schemain the CLI command.Additionally the output the CLI gives you where it loaded the.envfile from (which is next to the schema file) should also mention theschema.prismafile to make that explicit.Details about documentation of this feature are still figured out, as the schema loading is currently not documented at all directly.
Previous, slightly related documentation:
timsuchanek commentedon Sep 14, 2020
This is implemented by @Weakky in the latest dev version.
janpio commentedon Sep 14, 2020
Follow up issue about detail that got missed: #3647
sarink commentedon Jan 15, 2022
This is done? Where are the docs?
janpio commentedon Jan 16, 2022
Search for
schema locationon docs.prisma.io brings me to: https://www.prisma.io/docs/concepts/components/prisma-schema#prisma-schema-file-locationalphaelf commentedon Sep 11, 2022
can we use wildcard expression in package.json for schema location? just like:
janpio commentedon Sep 12, 2022
No, you can only specify exactly the location of the schema file you want it to read.
Security2431 commentedon Jun 25, 2024
See the official documentation:
https://www.prisma.io/docs/orm/prisma-schema/overview/location
marcospgp commentedon Sep 2, 2025
I like that
package.jsonwas used, I wish more libraries would standardize around it instead of polluting the project root with tons of independent config filesedit: spoke too soon