bernardopires / django-tenant-schemas

Tenant support for Django using PostgreSQL schemas.
https://django-tenant-schemas.readthedocs.org/en/latest/
MIT License
1.46k stars 424 forks source link

Apps from TENANT_APPS being referenced in public schema's auth_permission table. #633

Open sbhusal123 opened 4 years ago

sbhusal123 commented 4 years ago

Apps from TENANT_APPS being referenced in public schema's auth_permission table.

I'm facing issue while trying to delete user(auth model) from the main site(in the public schema). Actually, i've to implement multiple types of user in the tenant apps.

My settings.py look like:

SHARED_APPS = [
    'tenant_schemas',
    'Client',

    # for admin related stuffs
    'django.contrib.contenttypes',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.sessions',
    'django.contrib.messages',
    'common_auth_user',

    'rest_framework',

]

TENANT_APPS = [

    # authentication related stuffs
    'django.contrib.contenttypes',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.sessions',
    'django.contrib.messages',
    'common_auth_user', # holds auth user model

    'rest_framework',

    'app_level_user_types', # using foreign key to map to auth user
]

The problem is, every model from app_level_user_type app is being added to the permission tables(auth_permissions) on public schema during initial migration migate_schemas --shared, though they are meant to be in the tables of tenant specific schemas.