[Django]-Django migration hell, dropped a table. Tried to get it back

3👍

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.

5👍

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.

👤knbk

Leave a comment