umami-software / umami

Umami is a simple, fast, privacy-focused alternative to Google Analytics.
https://umami.is
MIT License
22.39k stars 4.17k forks source link

Command failed: prisma migrate deploy ERROR: "check-db" exited with 1. #2998

Open whysthatso opened 1 week ago

whysthatso commented 1 week ago

Describe the Bug

running docker compose up with an external postgresql 16 database

  1. first run
docker compose up
[+] Running 1/0
 ✔ Container umami_app  Created                                                                                                                                                                                                                                                                                       0.0s 
Attaching to umami_app
umami_app  | yarn run v1.22.19
umami_app  | $ npm-run-all check-db update-tracker start-server
umami_app  | $ node scripts/check-db.js
umami_app  | ✓ DATABASE_URL is defined.
umami_app  | ✓ Database connection successful.
umami_app  | ✓ Database version check successful.
umami_app  | ✗ Command failed: prisma migrate deploy
umami_app  | error Command failed with exit code 1.
umami_app  | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
umami_app  | ERROR: "check-db" exited with 1.
umami_app  | error Command failed with exit code 1.
umami_app  | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
umami_app exited with code 1
  1. running the migration through prisma separately:
docker compose run --rm app yarn prisma migrate deploy
yarn run v1.22.19
$ /app/node_modules/.bin/prisma migrate deploy
Prisma schema loaded from prisma/schema.prisma
Datasource "db": PostgreSQL database "umami", schema "public" at "db.whyservices.net:5432"

6 migrations found in prisma/migrations

Applying migration `01_init`
Applying migration `02_report_schema_session_data`
Applying migration `03_metric_performance_index`
Applying migration `04_team_redesign`
Applying migration `05_add_visit_id`
Applying migration `06_session_data`

The following migration(s) have been applied:

migrations/
  └─ 01_init/
    └─ migration.sql
  └─ 02_report_schema_session_data/
    └─ migration.sql
  └─ 03_metric_performance_index/
    └─ migration.sql
  └─ 04_team_redesign/
    └─ migration.sql
  └─ 05_add_visit_id/
    └─ migration.sql
  └─ 06_session_data/
    └─ migration.sql

All migrations have been successfully applied.
Done in 2.77s.
  1. running docker compose up again
docker compose up
[+] Running 1/0
 ✔ Container umami_app  Created                                                                                                                                                                                                                                                                                       0.0s 
Attaching to umami_app
umami_app  | yarn run v1.22.19
umami_app  | $ npm-run-all check-db update-tracker start-server
umami_app  | $ node scripts/check-db.js
umami_app  | ✓ DATABASE_URL is defined.
umami_app  | ✓ Database connection successful.
umami_app  | ✓ Database version check successful.
umami_app  | ✗ Command failed: prisma migrate deploy
umami_app  | error Command failed with exit code 1.
umami_app  | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
umami_app  | ERROR: "check-db" exited with 1.
umami_app  | error Command failed with exit code 1.
umami_app  | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
umami_app exited with code 1

Any idea how to further troubleshoot this?

Is there possibly a compatibility issue with postgres 16?

Database

PostgreSQL

Relevant log output

No response

Which Umami version are you using? (if relevant)

latest

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

selfhosted docker compose

franciscao633 commented 11 hours ago

I'm having the hardest time reproducing this error. Did you ever figure this out? Are you running with a local db in the compose file or connecting to an external db? I've tried both and can't get the prisma migrate deploy to fail on docker compose up. I've tested postgres 16 with the compose.yml below without issue

---
version: '3'
services:
  umami:
    image: ghcr.io/umami-software/umami:postgresql-latest
    ports:
      - '3000:3000'
    environment:
      DATABASE_URL: postgresql://umami:umami@db:5432/umami
      DATABASE_TYPE: postgresql
      APP_SECRET: replace-me-with-a-random-string
    depends_on:
      db:
        condition: service_healthy
    restart: always
    healthcheck:
      test: ['CMD-SHELL', 'curl http://localhost:3000/api/heartbeat']
      interval: 5s
      timeout: 5s
      retries: 5
  db:
    image: postgres:16.4
    environment:
      POSTGRES_DB: umami
      POSTGRES_USER: umami
      POSTGRES_PASSWORD: umami
    volumes:
      - umami-db-data:/var/lib/postgresql/data
    restart: always
    healthcheck:
      test: ['CMD-SHELL', 'pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}']
      interval: 5s
      timeout: 5s
      retries: 5
volumes:
  umami-db-data: