django migration hell, dropped a table. Tried to get it back

北城以北 提交于 2019-12-06 15:34:19

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!