Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if there are pending migrations when using SQLAlchemy/Alembic?

We're using SQLAlchemy and Alembic (along with Flask-SQLAlchemy and Flask-Migrate). How to check if there are pending migrations?

I tried to check both Alembic's and Flask-Migrate's documentation but failed to find the answer.

like image 554
arikfr Avatar asked Dec 27 '16 10:12

arikfr


1 Answers

You can figure out if your project as at the latest migration with the current subcommand:

Example output when you are at the latest migration:

(venv) $ python app.py db current f4b4aa1dedfd (head)

The key thing is the (head) that appears after the revision number. That tells you that this is the most recent migration.

Here is how things change after I add a new migration, but before I upgrade the database:

(venv) $ python app.py db current f4b4aa1dedfd

And after I run db upgrade I get:

(venv) $ python app.py db current f3cd9734f9a3 (head)

Hope this helps!

like image 94
Miguel Avatar answered Nov 04 '22 00:11

Miguel