Prisma error P3015 (Could Not Find the Migration File) explained: what it means, why it happens, and how to fix it — with copy-paste code examples.
Restore the missing file from version control: `git checkout -- prisma/migrations/...`. If that does not apply, if the migration was applied but its file is gone, recreate it from git history rather than deleting the row in _prisma_migrations — the full checklist is below.
Error code: P3015
Official name: Could Not Find the Migration File
Service: Prisma
Could not find the migration file at {migration_file_path}. Please delete the directory or restore the migration file.
git checkout -- prisma/migrations
npx prisma migrate status
Brings back deleted migration folders from version control and verifies the chain is complete.
Recover the file from git, then re-run migrate status to confirm the chain is intact.
git checkout -- prisma/migrations/
npx prisma migrate status
Make CI fail if the migrations folder is incomplete relative to the lock file.
- run: test -d prisma/migrations/migration_lock.toml
- run: npx prisma migrate status
Treat prisma/migrations as sacred: add it to git, never gitignore it.
# .gitignore: do NOT ignore prisma/migrations/*
Most often this happens when the migrations directory (or a single migration folder) was deleted or moved, or when a git merge/conflict resolution removed migration files that the database still references.
Restore the missing file from version control: `git checkout -- prisma/migrations/...`.
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.