django-tenant-schemas icon indicating copy to clipboard operation
django-tenant-schemas copied to clipboard

How to manage all tenants users/data from single public tenant(Root)

Open hpatel1 opened this issue 9 years ago • 4 comments

I want control of all tenants from one tenant which one is public. For example,

  • public schema - domain url is "localhost"
  • Tenant1 schema - domain url is "tenant1.localhost"
  • Tenant2 schema - domain url is "tenant2.localhost" Now from localhost, I want to add/remove users of tenant1 and tenant2 from their auth tables.

How can I do that?

hpatel1 avatar Feb 10 '16 06:02 hpatel1

Programmatically, you have 2 choices :

  • Change django.db.connection.schema_name to each schema when listing, editing, deleting users
  • Set search path to all schemas "SET search_path TO tenant2,tenant1,public" (execute a raw django query)

adimux avatar Apr 07 '16 19:04 adimux

AFAICT that second option doesn't work; it will only show/expose the auth_user table from tenant2.

wadevries avatar Jul 07 '16 08:07 wadevries

Is not there a solution for this where you can make a root tenant that can control all other tenants?

assem-ch avatar Oct 07 '18 10:10 assem-ch

I keep my tenants in the public schema, which are accessible from the other tenants as well. Seems to work just fine.

GeeWee avatar Mar 25 '19 14:03 GeeWee