This is due to a mismatch between the migrations that were executed against the database and the migrations in your prisma/migrations
folder.
This happens under the following circumstances:
- Create a migration with
prisma2 migrate save --name “init” --experimental
- Execute the migration with
prisma2 migrate up --experimental
- Delete the migration files in your
prisma/migrations
folder
- Try to run
prisma2 migrate save --name “new-migration” --experimental
At step 4 you will see that error.
Prisma keeps track of the executed migrations in the database in a table called _Migration
.
To solve the problem try to delete the _Migration
table in the database. With SQLite you can do it as follows:
sqlite3 prisma/dev.db "delete from _Migration"
If that doens't work, you need to recreate the database. If you’re using sqlite, delete the prisma/dev.db
file (you will lose all data in the database).
To prevent this in the future, make sure that you start with a clean database and if you reuse the same database avoid deleting migration files (in prisma/migrations
after they’ve been executed.