Chrome Extension

alembic.util.exc.CommandError: Can't locate revision identified by - Flask-migrate Error

I am using Flask-migrate for DB management in my Flask Python app. But when I execute the command

python manage.py db init

It executes successfully but when I execute the below migrate command in Terminal. It is showing Error

python manage.py db migrate

Error Text is - alembic.util.exc.CommandError: Can't locate revision identified by 'c30bb1ppb978'

1 Answers

You are getting this error because in your database there is a table named alembic_version which contains previous migrations names created by Flask-migrate. 

To get rid of the error Follow Steps

1. Find alembic_version table in your database by running below command

SELECT * FROM alembic_version;

2. Remove this table from databse by executing below SQL QUERY

DROP TABLE alembic_version;

Now you can run your commands of initialize database and migrate commands.

python manage.py db init


python manage.py db migrate

You will not get error this time because it will create new alembic_version table in database which will contains new migration info.

Never leave your website again in search of code snippets by installing our chrome extension.
Open Code Manager We are hiring