DEV Community

Le Vuong
Le Vuong

Posted on

Django - "manually" revert a migration.

Backup everything (DB, code) before you doing this. Be extra cautious if you are doing this on Production db/environment.

Steps are as below:

  • Delete the corresponding row in django_migrations table.
  • Revert/delete tables and/or any other changes made by the migration. Be careful with this step and make sure after this, your Django system state (db/files) is the same as before migration.
  • Remove the migration file (in app/migrations/00xx_) if you need to.

Notes:

  • Try to do this on a Test Django app to see that this is simple.
  • Learn more about Django migration (backward/forward/zero)

Top comments (0)