DEV Community

Sospeter Mong'are
Sospeter Mong'are

Posted on

Force Make migrations in Django

In Django, there's no official --force flag for makemigrations, but here are equivalent ways to forcefully regenerate migrations:


✅ Option 1: Delete old migrations, then regenerate

This is the cleanest way to "force" new migrations:

Step 1: Delete existing migration files

For example, for the app fundraiser:

find fundraiser/migrations/ -not -name "__init__.py" -delete
Enter fullscreen mode Exit fullscreen mode

Repeat for other apps (common, payment, etc.).

Or in Windows Git Bash:

find fundraiser/migrations/ ! -name "__init__.py" -type f -delete
Enter fullscreen mode Exit fullscreen mode

Step 2: Re-run makemigrations

python manage.py makemigrations
Enter fullscreen mode Exit fullscreen mode

Now Django will re-scan all models and generate fresh migrations as if from scratch.


✅ Option 2: Use --empty if you just need a placeholder

python manage.py makemigrations fundraiser --empty
Enter fullscreen mode Exit fullscreen mode

This doesn't inspect models, but gives you a blank migration file to edit manually (useful when Django doesn't detect changes).


✅ Option 3: Fake a clean slate

If you've already reset the database manually (e.g., dropped tables), and want Django to "believe" everything is in sync:

python manage.py migrate --fake
Enter fullscreen mode Exit fullscreen mode

Or after zeroing out:

python manage.py migrate appname zero --fake
python manage.py migrate appname --fake-initial
Enter fullscreen mode Exit fullscreen mode

⚠️ Be careful

  • Forcing migrations can break existing data.
  • Only do this if you're in development or know how to handle schema/data resets.

Top comments (0)