Open
Description
Hi, thank you for publishing this sample repo.
I'm having a problem - the app container doesn't connect to the database container.
Reproduction steps
- Clone repo
- Create
.env
file so it looks like this:
POSTGRES_USER=prisma
POSTGRES_PASSWORD=topsecret
POSTGRES_DB=food
# nest run in docker container
DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}?schema=food&sslmode=prefer
# nest run locally
# DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@localhost:5432/${POSTGRES_DB}?schema=food&sslmode=prefer
docker compose up
curl http://localhost:3000/foods
I'm getting {"statusCode":500,"message":"Internal server error"}%
in curl output.
Here are logs:
Details
$ docker compose up
Attaching to nest-api, postgresprisma
postgresprisma |
postgresprisma | PostgreSQL Database directory appears to contain a database; Skipping initialization
postgresprisma |
postgresprisma | 2024-01-16 22:08:32.262 UTC [1] LOG: starting PostgreSQL 13.13 (Debian 13.13-1.pgdg120+1) on aarch64-unknown-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
postgresprisma | 2024-01-16 22:08:32.263 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
postgresprisma | 2024-01-16 22:08:32.263 UTC [1] LOG: listening on IPv6 address "::", port 5432
postgresprisma | 2024-01-16 22:08:32.265 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgresprisma | 2024-01-16 22:08:32.267 UTC [27] LOG: database system was shut down at 2024-01-16 22:05:12 UTC
postgresprisma | 2024-01-16 22:08:32.271 UTC [1] LOG: database system is ready to accept connections
nest-api |
nest-api | > [email protected] start:prod /
nest-api | > node dist/main
nest-api |
nest-api | [Nest] 19 - 01/16/2024, 10:08:32 PM LOG [NestFactory] Starting Nest application...
nest-api | [Nest] 19 - 01/16/2024, 10:08:32 PM LOG [InstanceLoader] PrismaModule dependencies initialized +24ms
nest-api | [Nest] 19 - 01/16/2024, 10:08:32 PM LOG [InstanceLoader] AppModule dependencies initialized +1ms
nest-api | [Nest] 19 - 01/16/2024, 10:08:32 PM LOG [RoutesResolver] AppController {/}: +2ms
nest-api | [Nest] 19 - 01/16/2024, 10:08:32 PM LOG [RouterExplorer] Mapped {/, GET} route +1ms
nest-api | [Nest] 19 - 01/16/2024, 10:08:32 PM LOG [RouterExplorer] Mapped {/foods, GET} route +1ms
nest-api | [Nest] 19 - 01/16/2024, 10:08:32 PM LOG [NestApplication] Nest application successfully started +52ms
postgresprisma | 2024-01-16 22:09:38.937 UTC [34] ERROR: relation "food.Food" does not exist at character 54
postgresprisma | 2024-01-16 22:09:38.937 UTC [34] STATEMENT: SELECT "food"."Food"."id", "food"."Food"."name" FROM "food"."Food" WHERE 1=1 OFFSET $1
nest-api | [Nest] 19 - 01/16/2024, 10:09:38 PM ERROR [ExceptionsHandler]
nest-api | Invalid `this.prismaService.food.findMany()` invocation in
nest-api | /dist/app.controller.js:25:40
nest-api |
nest-api | 22 return this.appService.getHello();
nest-api | 23 }
nest-api | 24 getFoods() {
nest-api | → 25 return this.prismaService.food.findMany()
nest-api | The table `food.Food` does not exist in the current database.
nest-api | Error:
nest-api | Invalid `this.prismaService.food.findMany()` invocation in
nest-api | /dist/app.controller.js:25:40
nest-api |
nest-api | 22 return this.appService.getHello();
nest-api | 23 }
nest-api | 24 getFoods() {
nest-api | → 25 return this.prismaService.food.findMany()
nest-api | The table `food.Food` does not exist in the current database.
nest-api | at cb (/node_modules/@prisma/client/runtime/index.js:38504:17)
nest-api | at async /node_modules/@nestjs/core/router/router-execution-context.js:46:28
nest-api | at async /node_modules/@nestjs/core/router/router-proxy.js:9:17
postgresprisma | 2024-01-16 22:11:34.942 UTC [34] ERROR: relation "food.Food" does not exist at character 54
postgresprisma | 2024-01-16 22:11:34.942 UTC [34] STATEMENT: SELECT "food"."Food"."id", "food"."Food"."name" FROM "food"."Food" WHERE 1=1 OFFSET $1
nest-api | [Nest] 19 - 01/16/2024, 10:11:34 PM ERROR [ExceptionsHandler]
nest-api | Invalid `this.prismaService.food.findMany()` invocation in
nest-api | /dist/app.controller.js:25:40
nest-api |
nest-api | 22 return this.appService.getHello();
nest-api | 23 }
nest-api | 24 getFoods() {
nest-api | → 25 return this.prismaService.food.findMany()
nest-api | The table `food.Food` does not exist in the current database.
nest-api | Error:
nest-api | Invalid `this.prismaService.food.findMany()` invocation in
nest-api | /dist/app.controller.js:25:40
nest-api |
nest-api | 22 return this.appService.getHello();
nest-api | 23 }
nest-api | 24 getFoods() {
nest-api | → 25 return this.prismaService.food.findMany()
nest-api | The table `food.Food` does not exist in the current database.
nest-api | at cb (/node_modules/@prisma/client/runtime/index.js:38504:17)
nest-api | at async /node_modules/@nestjs/core/router/router-execution-context.js:46:28
nest-api | at async /node_modules/@nestjs/core/router/router-proxy.js:9:17
postgresprisma | 2024-01-16 22:11:37.499 UTC [34] ERROR: relation "food.Food" does not exist at character 54
postgresprisma | 2024-01-16 22:11:37.499 UTC [34] STATEMENT: SELECT "food"."Food"."id", "food"."Food"."name" FROM "food"."Food" WHERE 1=1 OFFSET $1
nest-api | [Nest] 19 - 01/16/2024, 10:11:37 PM ERROR [ExceptionsHandler]
nest-api | Invalid `this.prismaService.food.findMany()` invocation in
nest-api | /dist/app.controller.js:25:40
nest-api |
nest-api | 22 return this.appService.getHello();
nest-api | 23 }
nest-api | 24 getFoods() {
nest-api | → 25 return this.prismaService.food.findMany()
nest-api | The table `food.Food` does not exist in the current database.
nest-api | Error:
nest-api | Invalid `this.prismaService.food.findMany()` invocation in
nest-api | /dist/app.controller.js:25:40
nest-api |
nest-api | 22 return this.appService.getHello();
nest-api | 23 }
nest-api | 24 getFoods() {
nest-api | → 25 return this.prismaService.food.findMany()
nest-api | The table `food.Food` does not exist in the current database.
nest-api | at cb (/node_modules/@prisma/client/runtime/index.js:38504:17)
nest-api | at async /node_modules/@nestjs/core/router/router-execution-context.js:46:28
nest-api | at async /node_modules/@nestjs/core/router/router-proxy.js:9:17
I'll be very grateful for any help! I cannot seem to make Prisma work properly in my containerized Nest.js app.
Metadata
Metadata
Assignees
Labels
No labels