2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-11-13 19:36:46 +00:00

Catch error during auto-migrations (#10553) (#10560)

- Prevent process interlock
- Prevent migration check if already running migrations

(cherry picked from commit 067cb1fccb)

Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
This commit is contained in:
github-actions[bot]
2025-10-13 09:01:04 +11:00
committed by GitHub
parent fe1cc56e94
commit 4a83b98cd9

View File

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