Tried to migrate custom user model and got this error shown below

522 views
Skip to first unread message

FIRDOUS BHAT

unread,
Aug 9, 2020, 1:58:39 PM8/9/20
to Django users
django.db.migrations.exceptions.InconsistentMigrationHistory: Migration admin.0001_initial is applied before its dependency users.0001_initial on database 'default'.

Ayser shuhaib

unread,
Aug 9, 2020, 2:01:57 PM8/9/20
to django...@googlegroups.com
Truro delete the files inside the migrations folder then run The makemigrations command then migrate 

On Sun, 09 Aug 2020 at 19:58, FIRDOUS BHAT <frds...@gmail.com> wrote:
django.db.migrations.exceptions.InconsistentMigrationHistory: Migration admin.0001_initial is applied before its dependency users.0001_initial on database 'default'.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/94c323ed-996c-40a1-bb34-18339ee8d47co%40googlegroups.com.

Yemin Sajid

unread,
Aug 9, 2020, 2:18:52 PM8/9/20
to django...@googlegroups.com
If your project is not deployed to production yet, the easiest solution is to delete the whole existing database (sqlite db file or postgres/mysql database) and try to apply the migrations.

But if the project is already in the production, you would need to be careful with that. I would suggest
1. Make a backup of your data
2. Delete the tables of admin, auth and django_migration apps.
3. Apply the migrations
4. Insert the old users into your new custom user table.

Reply all
Reply to author
Forward
0 new messages