0

I am using flask-migrate to update the changes in my database. I ran this command. and then this command

$python manage.py db init
$python manage.py db migrate

I get the error below

alembic.util.exc.CommandError: Can't locate revision identified by 'e462fd034cc1'

I looked on stackoverflow for similar problems where it was suggested to deleted the migrations folder which i did but still same error is coming again and again. What should i do.

handsomer223
  • 885
  • 4
  • 12
  • 16

2 Answers2

0

Your database is out of sync with your migrations repository. For some reason the latest migration id stored in the database is not the migration id of a migration in your repository. This means that you probably deleted or modified the migration repository by hand and made it inconsistent with the current state of your database.

If this is a scratch database, maybe deleting and running the migrations again will fix the problem and give you a valid database.

Miguel Grinberg
  • 65,299
  • 14
  • 133
  • 152
0

Just see what is your last migration number. Open migrations/versions folder in any file manager and sort by date. For me, for example, it e222b725dce9_.py Then change the value in version_num column in alembic_version table

Note that I delete underscrore in the end

My phpMyAdmin

Then run python manage.py db migrate and python manage.py db upgrade All must pass successfully