OTF Umami Prisma Migration Crash Loop
resolvedWorkspace
[OTF] Optimified
Created
Mon Mar 23
Updated
Tue Mar 24
Content
## Description
After adding custom domain `analytics.optimified.com` and redeploying Umami (v3.0.3) on Railway, the service enters a crash loop. It repeatedly fails at the `check-db` step with Prisma error P3005:
```
Error: P3005
The database schema is not empty. Read more about how to baseline an existing production database: https://pris.ly/d/migrate-baseline
```
DB connection succeeds, version check passes, but `prisma migrate deploy` fails because the shared Postgres already has tables (from the existing Umami install) but no Prisma migration history (`_prisma_migrations` table is missing or empty).
The container restarts ~every 12 seconds in an infinite loop.
## Steps to Reproduce
1. Umami v3.0.3 running on shared Postgres in Railway project `otf-n8n-mattermost-umami`
2. Added custom domain `analytics.optimified.com`
3. Redeployed the service
4. Container starts, connects to DB, then crashes on `prisma migrate deploy`
## Root Cause
Shared Postgres has existing Umami tables but no `_prisma_migrations` tracking table. Prisma sees a non-empty schema and refuses to run migrations without a baseline. This is a known issue when upgrading Umami or when the DB was originally set up without Prisma migrations.
## Fix Options
1. **Baseline the database** — Run `prisma migrate resolve --applied <migration_name>` against the shared Postgres to mark existing migrations as applied. Requires Railway CLI or a one-off shell.
2. **Set `DISABLE_DB_CHECK=1`** — Umami env var that skips the `check-db` step entirely. Quick workaround if the schema is already correct.
3. **Fresh DB** — If Umami data is expendable, drop Umami's tables and let it recreate from scratch. Not ideal on shared Postgres.
Option 2 is the fastest path to get it running again.
## Resolution — RESOLVED 2026-03-23
`DISABLE_DB_CHECK` env var did not work on v3.0.3. Fix applied:
1. Set **pre-deploy command** to `npm run update-tracker` (runs before deploy)
2. Set **custom start command** to `npm run start-server` (skips `check-db` entirely)
3. Changed port from 3000 to **8080** (Umami v3.0.3 uses Next.js which defaults to 8080)
4. Custom domain `analytics.optimified.com` working after DNS-only verification + correct port
## Related
- Tech asset: [[otf-umami]]