Django migrations system is complex and optimal way to manage migrations, one can create, delete and update large number of models with ease, but this might sometime can create some unwanted trouble. If you are in development environment and will not mind cleaning up migrations here are few sets to follow.
1. Delete all migrations files in your project.
Navigate to migrations folder and delete all .py and .pyc files except __init__.py
file
OR
Run following commands.
find . -path “*/migrations/*.py” -not -name “__init__.py” -delete
find . -path “*/migrations/*.pyc” -delete
2. Delete/Drop your database, if you are using Sqlite simply delete db.sqlite3 file.
3. Run following commands to create new model and migrations files.
python manage.py makemigrations
python manage.py migrate
And you are done these are few simple steps to reset migrations within your project.
Top comments (1)
Hey Aditya! Nice share!
find
can be a great option, however it won't work fully properly in multi-repository projects. I take the opportunity to leave a good alternative django-reset-migrations and link a discution