fix migrations for template schema
Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space>
This commit is contained in:
parent
a5cc3c36ed
commit
3b98b1e386
|
@ -1,14 +1,18 @@
|
||||||
"""authentik tenants app"""
|
"""authentik tenants app"""
|
||||||
from django.db import DEFAULT_DB_ALIAS
|
from django.db import DEFAULT_DB_ALIAS
|
||||||
from django.db.models.signals import post_migrate
|
from django.db.models.signals import post_migrate
|
||||||
|
from django_tenants.utils import get_public_schema_name
|
||||||
|
|
||||||
from authentik.blueprints.apps import ManagedAppConfig
|
from authentik.blueprints.apps import ManagedAppConfig
|
||||||
|
|
||||||
|
|
||||||
def reconcile_default_tenant(*args, using=DEFAULT_DB_ALIAS, **kwargs):
|
def reconcile_default_tenant(*args, using=DEFAULT_DB_ALIAS, **kwargs):
|
||||||
"""Make sure default tenant exists"""
|
"""Make sure default tenant exists"""
|
||||||
|
from django_tenants.utils import schema_context
|
||||||
|
|
||||||
from authentik.tenants.models import Tenant
|
from authentik.tenants.models import Tenant
|
||||||
|
|
||||||
|
with schema_context(get_public_schema_name()):
|
||||||
Tenant.objects.using(using).update_or_create(
|
Tenant.objects.using(using).update_or_create(
|
||||||
defaults={"name": "Default", "ready": True},
|
defaults={"name": "Default", "ready": True},
|
||||||
schema_name="public",
|
schema_name="public",
|
||||||
|
|
Reference in New Issue