Django 1.7 migrations wont recreate a dropped table, why?

2024/11/19 1:44:28

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

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.

https://en.xdnf.cn/q/26492.html

Related Q&A

Reset ipython kernel

I was wondering if there is a way to restart the ipython kernel without closing it, like the kernel restart function that exists in the notebook. I tried %reset but that doesnt seem to clear the import…

What is the best way to remove a dictionary item by value in python? [duplicate]

This question already has answers here:Removing entries from a dictionary based on values(4 answers)Closed 4 years ago.I wonder if there is simple way to remove one or more dictionary element(s) from a…

How do I run a Python script on my web server?

Ive just started learning Python, and Im pretty lost right now. I want to run my script on my server that is hosted through hosting24.com. Their FAQ says they support Python, but I have no clue where t…

How to create an OrderedDict in Python?

I tried to maintain the order of a Python dictionary, since native dict doesnt have any order to it. Many answers in SE suggested using OrderedDict.from collections import OrderedDictdomain1 = { "…

How to log error to file, and not fail on exception

I am downloading a file from the net, and it fails even though I am doing: for p in query:try:except IOError as e:print e;If there is an error, I want to log it, and then continue on with the next file…

Suggestions for Python debugging tools? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site …

How can you bundle all your python code into a single zip file?

It would be convenient when distributing applications to combine all of the eggs into a single zip file so that all you need to distribute is a single zip file and an executable (some custom binary tha…

Pass Variable On Import

Lets say you have some time-consuming work to do when a module/class is first imported. This functionality is dependent on a passed in variable. It only needs to be done when the module/class is load…

Write a file to a directory that doesnt exist [duplicate]

This question already has answers here:How do I create a directory, and any missing parent directories?(27 answers)Closed 9 months ago.This post was edited and submitted for review 8 months ago and fa…

How to convert a string to an image?

I started to learn python a week ago and want to write a small program that converts a email to a image (.png) so that it can be shared on forums without risking to get lots of spam mails. It seems lik…