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.
Thanks, this was really helpful! I found that I had to use the command
python manage.py migrate accounts 0003
instead.