pythonmigrationalembic

How to clear history and run all migrations from the beginning?


How I can clear history using alembic? I couldn't find this option in alembic history. I want to run from the first migration rather than the last applied.


Solution

  • If you want to start with a fresh database, just drop the database, create a new one, then run the migrations. For example, with PostgreSQL:

    $ dropdb my_db
    $ createdb my_db
    $ alembic upgrade head
    

    Now you have a blank database with all the migrations applied.