Prisma "P3005: The database schema is not empty" (baseline) in CI
P3005 means the target database already has tables but the _prisma_migrations history is empty. Prisma will not guess which migrations were already applied, so you must baseline the existing schema.
What this error means
Against a pre-existing database, migrate deploy fails with "P3005 The database schema is not empty. Read more about how to baseline...".
Prisma
Error: P3005 The database schema is not empty. Read more about how to baseline an existing production database: https://pris.ly/d/migrate-baselineCommon causes
An existing schema with no migration history
The database was created outside Prisma (or seeded directly), so tables exist but no baseline migration is recorded.
A CI database restored from a snapshot
Restoring a schema dump populates tables without the _prisma_migrations records, tripping P3005.
How to fix it
Baseline the existing schema
- Create an initial migration from the current schema (diff to an empty database).
- Mark it already applied with
migrate resolve --applied. - Then run
migrate deployfor subsequent migrations.
Terminal
npx prisma migrate resolve --applied 0_init
npx prisma migrate deployStart CI from an empty database
If the CI database can be empty, migrate deploy applies all migrations cleanly with no baseline needed.
Terminal
npx prisma migrate reset --force
npx prisma migrate deployHow to prevent it
- Baseline any database that predates Prisma migrations.
- Prefer an empty ephemeral database per CI run.
- Do not restore raw schema dumps without recording migration history.
Related guides
Prisma "P3009: migrate found failed migrations in the target database" in CIFix Prisma "P3009: migrate found failed migrations in the target database" in CI - a prior migration is marke…
Prisma "migrate dev" prompts and fails in CI (use migrate deploy)Fix Prisma migrate hanging or failing in CI because `migrate dev` was used - it is interactive and may reset.…
Prisma "Drift detected: your database schema is not in sync" in CIFix Prisma "Drift detected: Your database schema is not in sync with your migration history" in CI - the data…