mirror of
https://github.com/inventree/InvenTree.git
synced 2025-10-14 21:22:20 +00:00
Catch error during auto-migrations (#10553)
- Prevent process interlock - Prevent migration check if already running migrations
This commit is contained in:
@@ -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)
|
||||
|
||||
|
Reference in New Issue
Block a user