fix migrations for template schema 3

Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space>
This commit is contained in:
Marc 'risson' Schmitt 2023-11-21 18:40:46 +01:00
parent 3b98b1e386
commit 89aa6539b2
No known key found for this signature in database
GPG Key ID: 9C3FA22FABF1AA8D
1 changed files with 5 additions and 1 deletions

View File

@ -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"""
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