How to Reset/Delete Migrations in Django

Django migrations are a powerful tool for managing changes to your database schema as your application evolves. However, there may be situations where you need to reset your migrations entirely, either due to a significant change in your database structure or to start fresh. In this blog, we will explore how to reset migrations in Django step by step.

Why Reset Migrations?

There are several scenarios where resetting migrations might be necessary:

  1. Database Structure Changes: If you’ve made significant changes to your database schema that are causing conflicts or errors, resetting migrations can help resolve these issues.
  2. Starting Fresh: Sometimes, you may want to start with a clean slate, especially in the development phase.
  3. Mistakes in Migrations: If you’ve made mistakes in your migrations and want to correct them, resetting migrations can be a way to do so.

Step 1: Backup Your Data

Before resetting migrations, it’s crucial to back up your data if you want to preserve it. You can use the dumpdata command to export your data to a fixture file:

python dumpdata > data.json

Step 2: Delete Migration Files

To reset migrations, you need to delete the migration files in your Django app’s migrations directory. These files are named sequentially. (e.g..,,, etc.).

rm -f your_app/migrations/0*

Note: Do not delete the file in the migrations directory.

Step 3: Reset the Database Schema

Next, you need to reset the database schema to its initial state. You can use the migrate command with the zero option to do this:

python migrate your_app zero

This command sets the database schema to an empty state

Step 4: Recreate Initial Migrations

After resetting the database schema, you should create new initial migration files:

python makemigrations your_app

This command generates a new initial migration based on the current state of your models.

Step 5: Apply Migrations

Now, apply the newly created migrations to recreate the database schema:

python migrate your_app

This will execute the initial migration and set up the database tables according to your. models.

Step 6: Restore Data (if necessary)

If you backed up your data in Step 1, you can restore it using the loaddata command:

python loaddata data.json

Step 7: Test Your Application

Finally, thoroughly test your Django application to ensure that everything works as expected with the reset migrations. Pay special attention to any database-related functionality to catch any issues that may arise.


Resetting migrations in Django can be a useful strategy in various scenarios, from resolving database conflicts to starting fresh. By following the steps outlined in this blog, you can safely reset your migrations and continue developing your Django application with confidence. Just remember to back up your data before starting the process to avoid data loss.

Blogs you might like to Read!