From 89aa6539b20608e9cddba94a499f044099abf289 Mon Sep 17 00:00:00 2001 From: Marc 'risson' Schmitt Date: Tue, 21 Nov 2023 18:40:46 +0100 Subject: [PATCH] fix migrations for template schema 3 Signed-off-by: Marc 'risson' Schmitt --- authentik/tenants/utils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/authentik/tenants/utils.py b/authentik/tenants/utils.py index bb000ed3c..c053c7470 100644 --- a/authentik/tenants/utils.py +++ b/authentik/tenants/utils.py @@ -1,9 +1,13 @@ """Tenant utils""" from django.db import connection +from django.db.utils import ProgrammingError from authentik.tenants.models import Tenant def get_current_tenant() -> Tenant | None: """Get tenant for current request""" - return Tenant.objects.filter(schema_name=connection.schema_name).first() + try: + return Tenant.objects.filter(schema_name=connection.schema_name).first() + except ProgrammingError: # We're inside a migration and this table doesn't exist yet + return None