From 067cb1fccbccd1f1458874d8c337bcb8e8d72177 Mon Sep 17 00:00:00 2001 From: Oliver Date: Mon, 13 Oct 2025 07:04:26 +1100 Subject: [PATCH] Catch error during auto-migrations (#10553) - Prevent process interlock - Prevent migration check if already running migrations --- src/backend/InvenTree/InvenTree/tasks.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/backend/InvenTree/InvenTree/tasks.py b/src/backend/InvenTree/InvenTree/tasks.py index 4e07f75bad..123ee4f966 100644 --- a/src/backend/InvenTree/InvenTree/tasks.py +++ b/src/backend/InvenTree/InvenTree/tasks.py @@ -670,6 +670,11 @@ def check_for_migrations(force: bool = False, reload_registry: bool = True) -> b Returns bool indicating if migrations are up to date """ + from . import ready + + if ready.isRunningMigrations() or ready.isRunningBackup(): + # Migrations are already running! + return False def set_pending_migrations(n: int): """Helper function to inform the user about pending migrations.""" @@ -720,6 +725,8 @@ def check_for_migrations(force: bool = False, reload_registry: bool = True) -> b if settings.DATABASES['default']['ENGINE'] != 'django.db.backends.sqlite3': raise e logger.exception('Error during migrations: %s', e) + except Exception as e: # pragma: no cover + logger.exception('Error during migrations: %s', e) else: set_pending_migrations(0)