You cannot revert a migration in Django but can migrate to a previous migration to apply the old changes on the database.
For example, consider the following as the last two migrations of the
my_app Django app:
If for some reason you want to undo the last migration (i.e. 0010_migration_to_revert), you can re-migrate to the previous migration using the following command:
./manage.py migrate my_app 0009_previous_migration
After migratiing to the previous migration, you can now delete migration ‘0010_migration_to_revert‘.
You can also reverse all migrations for an app. To do so, use
zero inplace of the migration name.
./manage.py migrate my_app zero
How to see old migrations of a Django app?
Using the following command you can list all migrations of
my_app Django app.
./manage.py showmigrations my_app