From 3b98b1e386bb0d334e5b6e954da3bbe129e16886 Mon Sep 17 00:00:00 2001 From: Marc 'risson' Schmitt Date: Tue, 21 Nov 2023 18:38:47 +0100 Subject: [PATCH] fix migrations for template schema Signed-off-by: Marc 'risson' Schmitt --- authentik/tenants/apps.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/authentik/tenants/apps.py b/authentik/tenants/apps.py index eecec031c..b3aef51a9 100644 --- a/authentik/tenants/apps.py +++ b/authentik/tenants/apps.py @@ -1,18 +1,22 @@ """authentik tenants app""" from django.db import DEFAULT_DB_ALIAS from django.db.models.signals import post_migrate +from django_tenants.utils import get_public_schema_name from authentik.blueprints.apps import ManagedAppConfig def reconcile_default_tenant(*args, using=DEFAULT_DB_ALIAS, **kwargs): """Make sure default tenant exists""" + from django_tenants.utils import schema_context + from authentik.tenants.models import Tenant - Tenant.objects.using(using).update_or_create( - defaults={"name": "Default", "ready": True}, - schema_name="public", - ) + with schema_context(get_public_schema_name()): + Tenant.objects.using(using).update_or_create( + defaults={"name": "Default", "ready": True}, + schema_name="public", + ) class AuthentikTenantsConfig(ManagedAppConfig):