From e7b7d03d141c019ba782a6abd7a4824c8af7eccc Mon Sep 17 00:00:00 2001 From: Matthias Mair Date: Mon, 8 Apr 2024 20:40:39 +0200 Subject: [PATCH] ignore TOTP migration if the model is not laoded --- .../users/migrations/0011_auto_20240119_1659.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/backend/InvenTree/users/migrations/0011_auto_20240119_1659.py b/src/backend/InvenTree/users/migrations/0011_auto_20240119_1659.py index 241ddd9ff4..fe0a0a12b5 100644 --- a/src/backend/InvenTree/users/migrations/0011_auto_20240119_1659.py +++ b/src/backend/InvenTree/users/migrations/0011_auto_20240119_1659.py @@ -2,7 +2,7 @@ import base64 -from django.db import migrations +from django.db import OperationalError, migrations from allauth.mfa.adapter import get_adapter from allauth.mfa.models import Authenticator @@ -13,6 +13,13 @@ from django_otp.plugins.otp_totp.models import TOTPDevice def move_mfa(apps, schema_editor): """Data migration to switch to django-allauth's new built-in MFA.""" adapter = get_adapter() + try: + TOTPDevice.objects.all().count() + except OperationalError: + # The table may not exist + print('Skipping totp migration as model does not exist') + return + authenticators = [] for totp in TOTPDevice.objects.filter(confirmed=True).iterator(): recovery_codes = set()