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...".
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.
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.
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.