Django manage.py: Migration applied before its dependency

This worked for me. I thank my coworker for sharing this knowledge after I searched online for many hours.

Start your db shell

python manage.py dbshell

Use the database you want. If you don’t know, run .databases (SQLite) or SHOW databases

mysql>use <database_name>;

Retrieve all the migrations under your app

mysql> select * from django_migrations where app='<app>';

You will see the output with ids next to all migrations. You may want to drop the migration that was applied before its dependency: <appname>.0016_auto_<date2>_<time2>. Say its id is 361:

mysql> delete from django_migrations where id=361;

Now out of the db shell, run python manage.py migrate again.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)