1

I accidentally manually dropped a data table. Now when I try to run my project I get an error that says: 1051 Unknown table error. Is there any way I can fix it it or am I screwed?

Keselme
  • 3,779
  • 7
  • 36
  • 68

2 Answers2

0

If you don't mind. Goto your app folders and delete all migration files. Delete all tables in the DB. then run migrations and migrate all over again to get your DB refreshed.

OR post the full error message you are getting..

Daniel Kilanko
  • 110
  • 1
  • 11
0

if you faced that same error.that error show because you made changes like creating, deleting, or updating a manual mistake in direct Database or PHPMyAdmin. then this error show like

MySQLdb._exceptions.ProgrammingError: (1146, "Table 'table name' doesn't exist"

in my case, I manually deleted the table in PHPMyAdmin. solution of error: You directly add the table in PHPMyAdmin and then delete all migration in project_app and add the table class in the model.py file

python manage.py makemigrations o/p: No migrations to apply.

python manage.py migrate o/p: No changes detected

then remove a table in the Model.py file

python manage.py makemigrations o/p: No migrations to apply.

python manage.py migrate o/p: No changes detected

then Add Table Class in the Model.py file

python manage.py makemigrations

o/p: Applying migrations

python manage.py migrate

o/p: Create model TableName

definitely you solve this error