Tuesday, January 29, 2019

Replicating a new database without using manage.py

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.





--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/af68cb61-01b4-44a0-9efc-faecb7c3f0fe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment