Let say you have migrations like this
project/apps/accounts/migrations
├── 0001_initial.py
├── 0002_historicalprofile_historicaluser.py
├── 0003_auto_20190807_1559.py
├── 0004_auto_20190811_1013.py
and currently you are in 0004_auto_20190811_1013.py
migrations.
and you want to undo migration or back to previous migration which is 0003_auto_20190807_1559.py
Use this command:
$ python manage.py migration accounts 0003
Note:
accounts
is the django app
You will see the output like:
Operations to perform:
Target specific migration: 0003_auto_20190807_1559, from accounts
Running migrations:
Rendering model states... DONE
Unapplying accounts.0004_auto_20190811_1013... OK
Your django database now in 0003_auto_20190807_1559.py
migrations.
Whats next?
Remove your 0004_auto_20190811_1013.py
file.
and you can start make new migrations.
Small note, if you want to reverse all migrations to the app (e.g. when you want to remove app) you can run
python manage.py migrate accounts zero
and start from scratch.