[Answered ]-How do I re-create databases after they were deleted?

2👍

It depends.

Did they delete all of the tables? If so thats easy. Just rerun the

manage.py migrate. 

Did they only delete new tables that you have added with migrations?
Not so bad, go into the django_migrations table, and delete the entries for the migrations that created the deleted tables from that table and rerun

manage.py migrate. 

When you run makemigrations, Django creates the migration file but doesn’t do anything with it in terms of touching the database.

When you run the migrate command, Django runs the alter table commands on the database and adds an entry to the django_migrations table, so it knows which migrations have been done, and which still need to be run.

If the person has deleted a random set of tables that are out of sync with your migrations its going to be a mess and its going to involve a lot of manual work to make sure your migrations and database tables are in sync.

Leave a comment