diff --git a/README.md b/README.md index 9cb50c6..37a7c46 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ pairing with smart people at Hashrocket. For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186). -_1252 TILs and counting..._ +_1253 TILs and counting..._ --- @@ -711,6 +711,7 @@ _1252 TILs and counting..._ - [Execute A Raw SQL Query](prisma/execute-a-raw-sql-query.md) - [Grab A Limited Set Of Records](prisma/grab-a-limited-set-of-records.md) +- [Specify Alternate Location For Prisma Schema](prisma/specify-alternate-location-for-prisma-schema.md) ### Python diff --git a/prisma/specify-alternate-location-for-prisma-schema.md b/prisma/specify-alternate-location-for-prisma-schema.md new file mode 100644 index 0000000..bac34ed --- /dev/null +++ b/prisma/specify-alternate-location-for-prisma-schema.md @@ -0,0 +1,28 @@ +# Specify Alternate Location For Prisma Schema + +By default, Prisma looks for a schema in one of two locations: + +- `./prisma/schema.prisma` +- `./schema.prisma` + +If it isn't in one of those two spots, then you'll get an error. + +You can manually specify an alternate location. One way is to use the +`--schema` flag with all `prisma` commands. A less tedious approach +([introduced in this PR](https://github.com/prisma/prisma/pull/3566)) is to +specify the location in your `package.json`. + +```json +{ + "prisma": { + "schema": "../../packages/database/prisma/schema.prisma" + } +} +``` + +This is handy in situations where your database schema and utils are packaged +up separately, like in a monorepo. Here is an example of [a monorepo +referencing a prisma schema in a separate +package](https://github.com/skillrecordings/products/blob/b10dece7170abcb9076221c0863549e2291541ae/apps/testingaccessibility/package.json#L201-L203). + +[source](https://www.prisma.io/docs/concepts/components/prisma-schema#prisma-schema-file-location)