Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Django DB Migration InconsistentMigrationHistory when running migrate

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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.

>Solution :

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
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading