Skip to content

Commit 9d16f2c

Browse files
committed
Add Specify Alternate Location For Prisma Schema as a Prisma TIL
1 parent a09c515 commit 9d16f2c

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
1010

1111
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
1212

13-
_1252 TILs and counting..._
13+
_1253 TILs and counting..._
1414

1515
---
1616

@@ -711,6 +711,7 @@ _1252 TILs and counting..._
711711

712712
- [Execute A Raw SQL Query](prisma/execute-a-raw-sql-query.md)
713713
- [Grab A Limited Set Of Records](prisma/grab-a-limited-set-of-records.md)
714+
- [Specify Alternate Location For Prisma Schema](prisma/specify-alternate-location-for-prisma-schema.md)
714715

715716
### Python
716717

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Specify Alternate Location For Prisma Schema
2+
3+
By default, Prisma looks for a schema in one of two locations:
4+
5+
- `./prisma/schema.prisma`
6+
- `./schema.prisma`
7+
8+
If it isn't in one of those two spots, then you'll get an error.
9+
10+
You can manually specify an alternate location. One way is to use the
11+
`--schema` flag with all `prisma` commands. A less tedious approach
12+
([introduced in this PR](https://github.com/prisma/prisma/pull/3566)) is to
13+
specify the location in your `package.json`.
14+
15+
```json
16+
{
17+
"prisma": {
18+
"schema": "../../packages/database/prisma/schema.prisma"
19+
}
20+
}
21+
```
22+
23+
This is handy in situations where your database schema and utils are packaged
24+
up separately, like in a monorepo. Here is an example of [a monorepo
25+
referencing a prisma schema in a separate
26+
package](https://github.com/skillrecordings/products/blob/b10dece7170abcb9076221c0863549e2291541ae/apps/testingaccessibility/package.json#L201-L203).
27+
28+
[source](https://www.prisma.io/docs/concepts/components/prisma-schema#prisma-schema-file-location)

0 commit comments

Comments
 (0)