Home > OS >  Django DB Migration InconsistentMigrationHistory when running migrate
Django DB Migration InconsistentMigrationHistory when running migrate

Time:07-06

I am unable to migrate my django after running python ./manage.py migrate.

This is what showmigrations is displaying

customerweb
 [X] 0001_initial
 [X] 0002_user_industry
 [X] 0003_auto_20220209_1737
 [X] 0004_userconfiguration_night_surcharge_exempt
 [ ] 0005_auto_20220614_1100
 [X] 0006_orderdelivery_is_order_unique
 [ ] 0007_orderdelivery_client_reference_no

I have tried --fake as well as trying to move back by one migrate using

python ./manage.py migrate <app_name> <000x_migrate_file>

all these is not working as the exeception keeps prompting InconsistentMigrationHistory. I have tried deleting the migration folders as well (keeping init only) but does not work as well.

CodePudding user response:

So Django admin expects a default auth model which is AUTH_USER_MODEL. Admin app apply migration as django's auth model Now since you changes the dependency hence the error. Please follow the below steps

  1. Take a backup of your database
  2. Comment out your created app in INSTALLED_APPS and AUTH_USER_MODEL = 'account.User' in your settings.py in project folder
  3. Run python manage.py admin zero
  4. Uncomment lines commented in step 2
  5. Run python manage.py migrate
  • Related