Wednesday, April 13, 2022

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

Issue

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.



Answered By - davidism
Answer Checked By - Candace Johnson (PHPFixing Volunteer)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.