Resetting Django Migrations Without Losing Data

This shows how to reset django migrations without losing any data. If you’ve deleted an app, this is also a great way of resetting migrations to prevent future conflicts.

  1. Drop the table ‘django_migrations’. If using mysql, the command is DROP TABLE 'django_migrations';
  2. In every app (appname), delete all files in appname/migrations except for
  3. Run ./ makemigrations. If using a custom user model (customuser), run ./ makemigrations customuser && ./ makemigrations
  4. Run ./ migrate --fake

the ‘django_migrations’ table will be automatically created.

This code was last tested on django 3.2.5

Leave a Reply

Your email address will not be published. Required fields are marked *