[Django]-How to redo makemigrations after getting an error?

8๐Ÿ‘

โœ…

1) Identify your last success migration:

./manage.py showmigrations mainapp
[X] 0001_initial
[X] 0002_auto_20160425_0102
[X] 0003_auto_20160426_2022
[X] 0004_auto_20160427_0036

2) Then use migrate to migrate your database to that specified migration point.

 ./manage.py migrate mainapp 0003_auto_20160426_2022

In this example Iโ€™m assuming the 0003 migration was success while the 0004 wasnโ€™t.

3) Remove the migration file

rm mainapp/migrations/0004_auto_20160427_0036.py*

4) Run makemigrations and migrate again.

๐Ÿ‘คslackmart

0๐Ÿ‘

If you have bad migration, you should simply remove it and generate it again.

๐Ÿ‘คGwynBleidD

Leave a comment