Very unusual migrations error (not what you think!)

I want to start by saying that I love Django and have been at it now for 2 years! I am having a very odd issue when I deploy and want to see if another Django fan could help me out. I will elaborate with errors, link to the project, and my understanding of the issue so far.

Preface:
I am using Heroku, and a Heroku provisioned Postgres Database.

If you want to dive right in, here is the GitHub & error:
GitHub

Error:
django.db.migrations.exceptions.InconsistentMigrationHistory: Migration admin.0001_initial is applied before its dependency profiles.0001_initial on database ‘default’.

I have fixed this problem before by following this article:
[Inconsistent Migration History - Using Django / Mystery Errors - Django Forum Inconsistent Migration History - #2 by KenWhitesell

I tried this approach, as well as restarting/reprovisioning the database, and completely rebuilding my project in hopes of finding where I went wrong.

The thing is that everything works perfectly when I use MySQL or SQLite. I use MySQL on my local machine and perfect! I used SQLite on the provisioned web app and the migrations worked. So, I provisioned the database and all the sudden I get the inconsistent migration history error. If I did not love Django so much THIS WOULD PUT ME IN A BAD MOOD AND I TELL YOU WHAT IM NOT GOING TO FREAK OUT OR ANYTHING!! :nerd_face:

Anyhow, could anyone speculate what would cause this to work perfectly on my databases but not Heroku’s?

What is the easiest, most fool proof method of deploying Django apps in your opinion?

Incase anyone else runs into this, I found an article which allowed me to get through it.

python - Django claiming inconsistent migration history on first migration - Stack Overflow

Basically, I had to remove the admin from installed apps and urls, migrate, then add it back.

I still do not know what caused the migrations to get messy, but this only happens whenever you extend the base user model. Also, Heroku uses Linux and I was running on Windows. Windows it worked perfect, Linux though… :rage:

1 Like