Add ability to configure custom schema location instead of requiring `--schema` arg
See original GitHub issueProblem
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:
{
"scripts": {},
"prisma": {
"schema": "db/schema.prisma"
},
"dependencies": {}
}
Alternatives
An alternative is to add a config file at the repo root, like .prisma.config.js
or something.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:34
- Comments:15 (11 by maintainers)
To keep this moving, I’d suggest we add support for
package.json
. It seems like there’s quite a bit of people want it and I don’t see any harm in supporting it.Later on, when we have imports, this solution can be our go-to for Go.
Some technical details for the implementation after discussion with @timsuchanek and @Jolg42:
--schema
or 2) fall back to./prisma/schema.prisma
(or./schema.prisma
) to find the schema file to load.package.json
file as defined in https://github.com/prisma/prisma/issues/3144#issuecomment-674820240.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 theschema.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.
Previous, slightly related documentation: