Django 1.7 migrations won't recreate a dropped table, why?

Prometheus picture Prometheus · Nov 3, 2014 · Viewed 26.3k times · Source

Using Django 1.7 migrations.

I accidentally dropped a table in my database. I assumed that by running migration again this would recreate the table but no, Django states "No migrations to apply".

How to I get Django to recreate the table?

I have run:

> makemigrations - No changes detected
> migrate - No migrations to apply.

I have tried making a change to the model and running a new migration and it simply states that "Table 'x.test_customer' doesn't exist" which is correct, but what I was hoping it that it would recreate the table.

Answer

J.Q picture J.Q · Jan 12, 2016

Go to your database and find the table django_migrations. Delete all the rows which have app equals your app name.

Then do a makemigrations & migrate will work.