prisma: migrate resolve: The migration could not be found
Bug description
Manually creating the folder “migrations” and a sub folder “whatever” and putting a “migration.sql” in it wont allow prisma migrate to resolve it.
How to reproduce
- have a database with whatever data in it already on your enviroment and call
npx prisma db pull
to create a schema. - call
npx prisma migrate diff --from-empty --to-schema-datamodel prisma/schema.prisma --script > migration.sql
- manually create a folder inside prisma’s folder called “migrations” and another child folder called “initial”
- drag the migration.sql file into “initial”
- run
npx prisma migrate status
to see, prisma knows that folder exists “1 migration found” - run
npx prisma migrate resolve --applied "initial"
- get error “The migration initial could not be found”
Expected behavior
especting the “_prisma_migrations” table to be created on the db and populated with the first migration marked as applied.
Prisma information
schema was generated calling npx prisma db pull
from the existing database
Environment & setup
- OS: Windows–>
- Database: Apache/2.4.38 (Debian) | 8.0.26 - MySQL Community Server - GPL
- Node.js version: v14.18.3
Prisma Version
Environment variables loaded from .env
prisma : 4.2.0
@prisma/client : 4.2.0
Current platform : windows
Query Engine (Node-API) : libquery-engine 2920a97877e12e055c1333079b8d19cee7f33826 (at node_modules\@prisma\engines\query_engine-windows.dll.node)
Migration Engine : migration-engine-cli 2920a97877e12e055c1333079b8d19cee7f33826 (at node_modules\@prisma\engines\migration-engine-windows.exe)
Introspection Engine : introspection-core 2920a97877e12e055c1333079b8d19cee7f33826 (at node_modules\@prisma\engines\introspection-engine-windows.exe)
Format Binary : prisma-fmt 2920a97877e12e055c1333079b8d19cee7f33826 (at node_modules\@prisma\engines\prisma-fmt-windows.exe)
Default Engines Hash : 2920a97877e12e055c1333079b8d19cee7f33826
Studio : 0.469.0
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 3
- Comments: 20 (5 by maintainers)
If you’re using VsCode and your
0_init/migration.sql
is in the wrong encoding you can:0_init/migration.sql
I just had the exact same problem as the original author of the issue and I also tried all the suggestions above but nothing worked. I can however confirm that the last suggestion from @janpio worked for me. Likewise, I just opened the
migration.sql
file in Notepad++ and changed the Encoding to UTF-8. After that, runningnpx prisma migrate resolve --applied initial
worked just fine.It works !
@ruanswanepoel This resolve to me! I really appreciate! Thanks!!!
Hey everyone here, we have a related issue that could be relevant for some of you: Are you on Windows and using PowerShell (e.g. via VS Code or IntelliJ) to create the migration file via
migrate diff
, and then it fails onmigrate resolve --applied
? Then this could be another case of this problem here: https://github.com/prisma/prisma/issues/17558#issuecomment-1410856229