Codesnippet.dev
</>

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.
Warning

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 "__init__.py" -delete
find . -path "*/migrations/*.pyc" -delete
./manage.py run makemigrations
./manage.py migrate --fake