Prisma throws P3005 when you run an initial migration against a database that already contains tables. The CLI refuses to run until you either baseline the current schema or start from a clean database. Resolve the existing schema before rerunning Prisma Migrate so future migrations have a recorded history.
Prisma Migrate enforces P3005 on the very first migration to protect existing databases. When the CLI detects tables, views, or other objects but cannot find a recorded migration history, it stops with "The database schema is not empty" so you do not accidentally overwrite or misalign production data. This usually happens when you try to apply Prisma migrations to a legacy database, a restore from production, or any schema that was created before the current migration pipeline existed. Even if you generated the same schema with `prisma db push`, the migration engine still expects a clean slate for the first migration so it can record the initial state inside `_prisma_migrations`. The safest path forward is to treat the current schema as a baseline: introspect or inspect it so Prisma knows what the database already looks like, record that baseline migration as applied, and then run new migrations on top of that. Alternatively, work against an empty clone of the database so the CLI can bootstraps migrations without confusion.
Confirm that the database already has objects and that Prisma has no recorded baseline yet:
npx prisma migrate status
# Then list tables (PostgreSQL example)
psql "$DATABASE_URL" -c 'dt'
# Or query information_schema (MySQL example)
mysql --execute 'SELECT table_name FROM information_schema.tables WHERE table_schema = DATABASE();'Look for existing tables and for the absence of an applied migration inside _prisma_migrations. This explains why Prisma stops with P3005.
If you want to keep the current schema and data, tell Prisma about it before generating new migrations:
# Introspect the schema so your Prisma schema matches production
npx prisma db pull
# Create a migration that captures the current state without applying it
npx prisma migrate dev --create-only --name init
# Mark that migration as already applied in the database
npx prisma migrate resolve --applied initNow the database has an entry in _prisma_migrations, and future prisma migrate dev runs will build on top of the baseline instead of re-running it.
If you can recreate the database, drop the existing schema and let Prisma run the first migration on an empty database:
npx prisma migrate reset --force
# Or manually drop and recreate schemas:
psql "$DATABASE_URL" -c 'DROP SCHEMA public CASCADE; CREATE SCHEMA public;'
npx prisma migrate devAlways back up your data first. Resetting is safest for development copies, not production.
After baselining, keep migrations deterministic:
npx prisma migrate status
npx prisma migrate deploy # for productionShare the baseline migration with teammates, and avoid running prisma migrate dev against shared or production databases without a dedicated migration history. If your workflow still needs to refresh dev copies often, script the baseline steps so they repeat reliably.
Deploy-time behavior: Prisma Migrate always runs the baseline migration only once per database. Use prisma migrate deploy on environments where you have already resolved the baseline, and Prisma will skip the resolved migration automatically.
Shadow database: When you run prisma migrate dev, Prisma also compares the schema against a shadow database. Make sure the shadow URL points to an empty schema, otherwise the comparison may also trigger P3005-like complaints.
Prisma db push: db push can sync your schema to an existing database, but it does not touch migration history. Run the baseline steps before switching to migration-based workflows.
P1013: The provided database string is invalid
The provided database string is invalid
P1000: Authentication failed against database server
Authentication failed against database server
P1010: User was denied access on the database
How to fix "P1010: User was denied access on the database" in Prisma
P5008: Usage exceeded, upgrade your plan (Accelerate)
How to fix "Usage exceeded, upgrade your plan" in Prisma Accelerate
P3021: Foreign keys cannot be created on this database
How to fix 'P3021: Foreign keys cannot be created on this database' in Prisma