From 4a83b98cd96e2fc43d1fa5784cce1fb6b28f5c84 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 13 Oct 2025 09:01:04 +1100 Subject: [PATCH] Catch error during auto-migrations (#10553) (#10560) - Prevent process interlock - Prevent migration check if already running migrations (cherry picked from commit 067cb1fccbccd1f1458874d8c337bcb8e8d72177) Co-authored-by: Oliver --- 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 9903a04ac0..024753567f 100644 --- a/src/backend/InvenTree/InvenTree/tasks.py +++ b/src/backend/InvenTree/InvenTree/tasks.py @@ -668,6 +668,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.""" @@ -718,6 +723,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)