Prisma Error P3005: Database Schema Is Not Empty

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.

Error code P3005 Prisma Last verified 2026-08-19

Quick Answer

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

Error code: P3005
Official name: Database Schema Is Not Empty
Service: Prisma

What does this error mean?

The database schema is not empty. Read more about how to baseline an existing production database: https://pris.ly/d/migrate-baseline

Common Causes

How to Fix

  1. Decide whether the existing schema must be preserved (production data) or can be dropped (dev scratch)
  2. For a brand-new dev database: drop it and let `prisma migrate dev` recreate everything from scratch
  3. For production: create a baseline migration with `npx prisma migrate resolve --applied 0_init` so Prisma treats the current state as already migrated
  4. Alternative: run `npx prisma db pull` to import the existing schema into your Prisma schema, then `prisma migrate diff` to build the baseline migration file
  5. Verify with `npx prisma migrate status` that everything shows as Applied before deploying new migrations

Code Examples

Baseline with resolve --applied bash
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.

Import the live schema instead bash
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.

Framework-Specific Fixes

prisma-cli

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
github-actions

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
nestjs

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

You Might Also Like

Frequently Asked Questions

Why am I seeing Prisma error P3005?

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.

How do I fix Prisma error P3005?

Decide whether the existing schema must be preserved (production data) or can be dropped (dev scratch).

Which frameworks have documented fixes for error P3005?

This page documents fixes for: prisma-cli, github-actions, nestjs.

Official Sources

This page is based on the official Prisma documentation linked below and adds practical troubleshooting guidance on top.