1

Please help me to change the default schema from public to custom_schema. Also I am using the tenant to create the multiple tenants for the same base custom_schema tables.

1 Answers1

2

if you want to use only one schema, it is enough that add options to db configuration in settings.py. You should create a new schema called 'custom_schema' before migration.

DATABASES = {

'default': {
    'ENGINE': 'django.db.backends.postgresql_psycopg2',
    'OPTIONS': {
        'options': '-c search_path=custom_schema'
    },
    'NAME': 'name',
    'USER': 'user',
    'PASSWORD': 'password',
   }
}

If you want to use more than one schema, add a second db configuration to the db configuration with only the schema name different. Then write a router to decide which db will work in which situations.

https://docs.djangoproject.com/en/4.1/topics/db/multi-db/

koksal
  • 161
  • 4