CommandError: Can't locate revision identified by '...' when migrating using Flask-Migrate CommandError: Can't locate revision identified by '...' when migrating using Flask-Migrate flask flask

CommandError: Can't locate revision identified by '...' when migrating using Flask-Migrate


you delete the migration directory but the version has been saved in the database, so you have to delete the version info in the dabase,run

delete from alembic_version;

in mysql shell.

As suggested by @mirekphd, If this is a developing environment or a single app for test, just delete it, Else BACKUP the data in the table.


In my case I have accidentally deleted the most recent migration file but the alembic version (alembic_version) table refers to the deleted version.

So instead of droping the entire database, you can change the version_num field in the alembic_version table.

Following steps worked for me:

  • Find the head using db history
  • Update the version_num field to the head version.
  • run migrate using db migrate
  • upgrade the database db upgrade


I try this on flask and it solve!

python app.py db revision --rev-id e39d16e62810
python app.py db migrate
python app.py db upgrade