Replicating a new database without using manage.py

已查看 19 次
跳至第一个未读帖子

pastrufazio

未读,
2019年1月29日 10:40:222019/1/29
收件人 Django users
Hi all,

I'm creating multi-tenancy capabilities for out back-end application and I need to create a separate database for every current tenant.

Playing around with pg_dump and pg_restore, I noticed that a new restored PostgreSQL database is fully functional and I don't need to use the proper makemigrations+migrate procedure.

Then I can log in into the admin interface of the Django app and delete all the extraneous data leaving just the one related to the tenant.

Do you see any inconvenience in proceeding this way?

Below the procedure I use (cleansed of host, port and user options):

/usr/bin/pg_dump -Ft --no-acl --no-owner <ORIGIN_DB> -f /tmp/dump.tar
/usr/bin/pg_restore -n public -d <DESTINATION_DB> /tmp/dump.tar

Thank you very much.





回复全部
回复作者
转发
0 个新帖子