Database migration in Django deletes the table after mistakenly deleting the table

1. Execute
python manage.py makemigrations
python manage.py migrate is
invalid, and there is no table in the database

2. Solution
: Find the record table for database migration in the database and find the table name ID that needs to be migrated

First enter mysql, and then execute show tables; find the django_migrations table, and then find the id of the initial file in the table (this is the file you performed before the migration)

Perform deletion: delete from django_migrations where id = (id you find out);

Finally, execute:
python manage.py makemigrations
python manage.py migrate
to see the database, there are definitely tables

Published 129 original articles · Like 43 · Visits 100,000+

Guess you like

Origin blog.csdn.net/nbxuwentao/article/details/105588653