Search code examples
pythonflaskalembicflask-migrate

How do I find the latest migration created w/ flask-migrate?


My flask application now has 20+ migrations built with flask-migrate and they all have hashed file names like: 389d9662fec7_.py

I want to double check the settings on the latest migration that I ran, but don't want to open every file to look for the correct one. I could create a new dummy migration and look at what it references as the down_revision but that seems clunky.

I'm using flask-script, flask-migrate, and flask-sqlalchemy

My question is: How can I quickly find the latest migration that I created?


Solution

  • ./manage.py db history -r current: will show the migrations in the order they will be applied. -r current: shows only the migrations since the currently applied one.

    ./manage.py db heads will show the most recent migration for each branch (typically there's only one branch). ./manage.py db upgrade would apply all migrations to get to the head.

    Use the -v flag to get verbose output, including the full path to the migration.