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
Copy file name to clipboardExpand all lines: backend/README.md
+25Lines changed: 25 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,6 +31,31 @@ We use Prisma as our ORM to interact with PostgreSQL.
31
31
- Schema is located at `prisma/schema.prisma`.
32
32
- Run `npx prisma studio` to view the database through a web UI.
33
33
34
+
### `prisma.config.ts` vs `prisma/schema.prisma`
35
+
36
+
There are two Prisma files, and they do different jobs:
37
+
38
+
| File | Owns |
39
+
| ---- | ---- |
40
+
|`prisma/schema.prisma`| The **data model** — models, enums, relations, the `datasource` and `generator` blocks. This is what `prisma generate` turns into the client. |
41
+
|`prisma.config.ts`| The **Prisma CLI configuration** — where the CLI looks for things and how it connects when you run `prisma generate`, `prisma migrate`, `prisma db push`, or `prisma studio`. |
42
+
43
+
`prisma.config.ts` exists as a separate file because it is TypeScript that Node evaluates before the CLI runs, so it can do things `schema.prisma` cannot — most importantly read environment variables. Prisma 7 (this project is on `prisma@^7.4.1`) no longer auto-loads `.env` for CLI commands, which is why the file starts with `import "dotenv/config"`.
44
+
45
+
What it currently sets:
46
+
47
+
-`schema: "prisma/schema.prisma"` — path to the schema, so CLI commands work from the `backend/` directory without a `--schema` flag.
48
+
-`migrations.path: "prisma/migrations"` — where migration folders are read from and written to.
49
+
-`datasource.url: process.env["DATABASE_URL"]` — the connection string the CLI uses.
50
+
51
+
### Troubleshooting
52
+
53
+
If a `prisma generate` / `prisma migrate` command misbehaves, check `prisma.config.ts` before assuming the schema is at fault:
54
+
55
+
-**"Environment variable not found: DATABASE_URL"** or the CLI connecting to the wrong database — the config resolves `DATABASE_URL` at load time via `dotenv/config`, so it reads `backend/.env`. A variable exported only in your shell after the process starts, or set in a `.env` outside `backend/`, will not be picked up.
56
+
-**CLI can't find the schema or migrations** — these paths are relative to `backend/`. Running `prisma` from the repo root will not resolve them.
57
+
-**`npm run prisma:seed` not running the seed script** — the seed command is declared in the legacy `prisma.seed` field in `package.json`. Prisma 7 expects it as `migrations.seed` in `prisma.config.ts`, so if seeding silently does nothing, check both places.
58
+
34
59
## /v1 API
35
60
36
61
All REST API endpoints are prefixed with `/v1`. Refer to the API Documentation in the root `README.md` and the `docs/` folder for versioning and authentication details.
Copy file name to clipboardExpand all lines: docs/DEVELOPMENT.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -68,6 +68,8 @@ npm run prisma:generate
68
68
npm run prisma:migrate
69
69
```
70
70
71
+
These commands read their paths and connection string from `backend/prisma.config.ts`, which configures the Prisma CLI separately from the data model in `backend/prisma/schema.prisma`. See [Prisma Database](../backend/README.md#prismaconfigts-vs-prismaschemaprisma) in the backend README for what each file owns and what to check when a `generate`/`migrate` command misbehaves.
72
+
71
73
Start backend:
72
74
73
75
```bash
@@ -199,6 +201,7 @@ Configure in `.env`:
199
201
* Check `DATABASE_URL`
200
202
* Run `prisma generate`
201
203
* Reset DB if schema drift occurs
204
+
* Check `backend/prisma.config.ts` — it sets the schema path, migrations path, and the `DATABASE_URL` the CLI uses ([details](../backend/README.md#troubleshooting))
0 commit comments