简体   繁体   中英

How to restore Django project with pg_dump file?

What is the procedure to restore a Django project using an already restored database from a PostgreSQL pg_dump. All django source code also exist. Will Django migration safe?

If your dump has create table statements and contains all django tables, you can restore it directly onto an empty database. Django will know the status of the migrations as they are stored in a table in the DB.

So the steps would be:

  1. Drop and recreate DB.

    If you now run python manage.py showmigrations all migrations will appear unapplied

  2. Restore DB from dump

    If you now run python manage.py showmigrations now, the corresponding migrations will appear applied. If your django project has new migrations that weren't applied when the dump was created they will appear unapplied.

And that's it! Now you can apply the new migrations if there are any and keep working on the Django project.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM