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.
In my case in
django 2.0.2
for recreating dropped table I needed to comment my models inmyapp
and then migrate with--fake
and uncomment my models and migrate without--fake
A little different from raul answer:DELETE FROM django_migrations WHERE app = 'app_name'
.models.py
and all this models usage inviews
,signals
and etc (to prevent error).python manage.py makemigrations YOUR_APP_NAME
python manage.py migrate --fake
python manage.py makemigrations YOUR_APP_NAME
python manage.py migrate
This should solve some users problem.
Another solution I've found and works perfectly:
In django 1.7:
Delete your migrations folder
In the database:
DELETE FROM django_migrations WHERE app = 'app_name'
.You could alternatively just truncate this table.
python manage.py makemigrations
python manage.py migrate --fake
In django 1.9.5:
In the database:
DELETE FROM django_migrations WHERE app = 'app_name'
.You could alternatively just truncate this table.
python manage.py makemigrations app_name
python manage.py migrate
This works 100% for me!
Go to your database and find the table
django_migrations
. Delete all the rows which haveapp
equals your app name.Then do a
makemigrations
&migrate
will work.