How to reset Django migrations during development

When using Django, sometimes you want to completely reset migrations before your applications hits production.

Django stores information about migrations on 2 places:

  1. In a DB, specifically in django_migrations table where it stores information about what migrations were applied.
  2. In a filesystem, where migrations are basically defined.

Migrations are an important part of Django framework and you can only hard-delete them this way before you hit production.

In your database:

TRUNCATE django_migrations;

In your shell:

find . -path "*/migrations/*.py" -not -name "" -delete
find . -path "*/migrations/*.pyc" -delete
./ run makemigrations
./ migrate --fake