Prisma error P3005 (Database Schema Is Not Empty) explained: what it means, why it happens, and how to fix it — with copy-paste code examples.
Decide whether the existing schema must be preserved (production data) or can be dropped (dev scratch). If that does not apply, for a brand-new dev database: drop it and let `prisma migrate dev` recreate everything from scratch — the full checklist is below.
Error code: P3005
Official name: Database Schema Is Not Empty
Service: Prisma
The database schema is not empty. Read more about how to baseline an existing production database: https://pris.ly/d/migrate-baseline
npx prisma migrate resolve --applied 0_init
npx prisma migrate status
Records 0_init as already applied, telling Prisma the current schema predates migrations. From here new migrations layer on top.
npx prisma db pull
npx prisma migrate diff \
--from-empty --to-schema-datamodel prisma/schema.prisma \
--script > prisma/migrations/0_init/migration.sql
Generates a real baseline migration from the running database instead of marking it applied.
Baseline an existing database so migrate knows the current schema is already applied.
# 1) mark the current state as already migrated:
npx prisma migrate resolve --applied 0_init
# 2) or import the live schema instead:
npx prisma db pull
Only run migrate deploy against databases that already have a baseline; guard the first deploy with a manual approval step.
environment: production
steps:
- run: npx prisma migrate deploy
# first deploy requires a baseline migration committed first
Keep a README in the repo documenting how the staging/prod database was baselined so new developers do not hit P3005.
# docs/migrations.md
# Existing prod DB -> baseline:
# npx prisma migrate resolve --applied 0_init
# npx prisma migrate dev
Most often this happens when pointing prisma migrate at an existing production database that already has tables (no baseline migration yet), or when reusing a database that another app or a previous schema version created.
Decide whether the existing schema must be preserved (production data) or can be dropped (dev scratch).
This page documents fixes for: prisma-cli, github-actions, nestjs.
Recommendations are editorial — DB Error Reference takes no payment or affiliate fees for tool listings.
This page is based on the official Prisma documentation linked below and adds practical troubleshooting guidance on top.