shaare.it

MigrationError: Inconsistent migration state

7 Dec 2025

1 min read

MigrationError: Inconsistent migration state

$ python manage.py migrate
# Errors show that migration file is missing/applied mismatch

Why this happens

Migration history doesn’t match migration files due to rebases or file deletions.

Fix

Recreate missing migrations, use --fake or --fake-initial appropriately, and align DB state with code.

Wrong code

# Deleted 0002 but DB has it applied

Fixed code

# Restore 0002 or fake-unapply/apply to reconcile
# python manage.py migrate app 0002 --fake