Is there a simple way to tell alembic to migrate to a specific revision?

Matt picture Matt · May 4, 2016 · Viewed 10.8k times · Source

Alembic has commands to upgrade and downgrade to a specific revision, e.g. on the command line:

alembic upgrade <target-revision>

And

alembic downgrade <target-revision>

Is there a simple way to migrate to a specific revision if you don't know whether it's an upgrade or a downgrade? i.e.

alembic migrate <target-revision>

I can work out the direction by looking at the history, current and target revisions, but this feels like fighting the library. Am I missing something or is there a reason why this isn't provided out of the box?

Answer

Matt picture Matt · May 7, 2016

It turns out there's a very simple, pragmatic solution to this:

alembic upgrade <target-revision> || alembic downgrade <target-revision>