Prisma migration files are missing or out of sync with your database. This error occurs when the migration directory exists but the migration.sql file is absent, often after git operations or branch switching.
The P3015 error happens when Prisma Migrate detects a migration directory in your `prisma/migrations/` folder, but the actual `migration.sql` file inside it is missing. This creates an inconsistency between your migration history and the file system. This typically occurs when: - You rolled back a git commit that included migrations - You switched between git branches with different migration histories - Migration files were deleted manually or by a file sync - Your local migrations folder is out of sync with source control Prisma tracks applied migrations in the `_prisma_migrations` database table. When it can't find the corresponding migration file, it throws P3015 because it doesn't know whether the migration was applied or needs to be applied.
The error message will show you the exact path to the missing migration file. For example:
P3015: Could not find the migration file at /Users/name/project/prisma/migrations/20250103154636_add_users_table/migration.sql. Please delete the directory or restore the migration file.Note down the timestamp and name of the migration (e.g., 20250103154636_add_users_table).
Look at recent commits to see if this migration was part of a branch you're switching away from:
git log --oneline -- "prisma/migrations/20250103154636_add_users_table/"If the migration appears in a previous commit that you reverted, this confirms the git branch issue.
The safest solution in development is to delete the empty migration directory:
rm -rf prisma/migrations/20250103154636_add_users_table/Then run:
npx prisma migrate devPrisma will ask if you want to reset the database. In development, this is usually safe and recommended.
If you're in production or need to preserve data, restore the migration.sql file from git:
git checkout HEAD~1 -- "prisma/migrations/20250103154636_add_users_table/migration.sql"Replace HEAD~1 with the appropriate commit that had the migration. Then run:
npx prisma migrate deployIf multiple migrations are corrupted, consider a clean reset:
# Delete all migrations (backup first!)
rm -rf prisma/migrations/
# Recreate initial migration from current schema
npx prisma migrate dev --name initThis creates a single init migration that represents your entire current schema. Use this only if you're okay losing the granular migration history.
For production databases, always use prisma migrate resolve instead of deleting:
# Mark the migration as rolled back so it can be reapplied
npx prisma migrate resolve --rolled-back "20250103154636_add_users_table"
# Then reapply it
npx prisma migrate deployBranch strategy tip: If your team frequently switches branches with different migrations, ensure everyone always commits both the migration directory AND the updated prisma/migrations/migration_lock.toml file to git. Missing the lock file causes similar issues.
Windows PowerShell issue: There's a known bug on Windows PowerShell where migration files can be created with UTF-16 LE encoding instead of UTF-8. If you created migrations on Windows, verify the encoding:
file prisma/migrations/*/migration.sqlIf it shows "UTF-16 LE", convert it back to UTF-8 using a text editor or tool.
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