raise InconsistentMigrationHistory

Sometimes, when I mess around, I get this error when I try to migrate:

    raise InconsistentMigrationHistory(
django.db.migrations.exceptions.InconsistentMigrationHistory: Migration socialaccount.0001_initial is applied before its dependency sites.0001_initial on database 'default'.

What does this mean?

And how should I go about fixing it without wholly dropping my database?

What exactly do you mean by

?

If at any time you are deleting migration files, don’t do that unless you become really familiar with how migrations work.

See:

and get familiar with the migrations table that Django creates in your database.

You generally can resolve problems like this, but fixing it is going to (possibly) involve editing some number of migration files and manually editing the migrations table.

for example, adding 'django.contrib.sites', to INSTALLED_APPS creates this error for me.

I fixed the problem by dropping a few rows in the django_migration table and dropping any socialaccount table related to allauth.