So I dropped a table in my database, and I want it back. Rerunning a migration gave errors table didn't exist. After some hunting I learned I could remove everything in my django_migrations that had app name my app. So i did that, reran migrations it started to work then griped about tables that were not dropped.
I have no idea how to just get the one table back again and keep everything as it was... anyway to do this?
I don't care about 90% of the data in the database, only a few tables and fields. The table i dropped i cared nothing about the data.
Start by inspecting the django_migrations
table. It contains data about which migrations have already run. Compare this data to the actual migrations files to learn which ones have run or not.
Finally, don't be afraid to delete rows in django_migrations
and modify your original migrations files to recreate the tables you need.
You can use the sqlmigrate command to print the SQL commands that Django would execute. Then you can pick the commands necessary to recreate the tables you removed and apply them manually.
Once all the tables are in place again, you can use migrate <app_name> --fake
to forward the migration history, so Django knows that the migrations in this app are applied.