mirror of
https://github.com/inventree/InvenTree.git
synced 2025-10-15 05:32:21 +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
|
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):
|
def set_pending_migrations(n: int):
|
||||||
"""Helper function to inform the user about pending migrations."""
|
"""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':
|
if settings.DATABASES['default']['ENGINE'] != 'django.db.backends.sqlite3':
|
||||||
raise e
|
raise e
|
||||||
logger.exception('Error during migrations: %s', e)
|
logger.exception('Error during migrations: %s', e)
|
||||||
|
except Exception as e: # pragma: no cover
|
||||||
|
logger.exception('Error during migrations: %s', e)
|
||||||
else:
|
else:
|
||||||
set_pending_migrations(0)
|
set_pending_migrations(0)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user