2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-17 18:26:32 +00:00

Maintenance Mode Improvements (#6451)

* Custom migration step in tasks.py

- Add custom management command
- Wraps migration step in maintenance mode

* Rename custom management command to "runmigrations"

- Add command to isRunningMigrations

* Add new data checks

* Update database readiness checks

- Set maintenance mode while performing certain management commands

* Remove unused import

* Re-add syncdb command

* Log warning msg

* Catch another potential error vector
This commit is contained in:
Oliver
2024-02-08 12:47:49 +11:00
committed by GitHub
parent 8b62f7b2c0
commit 633fbd37bd
9 changed files with 153 additions and 72 deletions

View File

@@ -12,6 +12,8 @@ from django.conf import settings
from django.core.exceptions import AppRegistryNotReady
from django.db.utils import IntegrityError, OperationalError, ProgrammingError
from maintenance_mode.core import maintenance_mode_on, set_maintenance_mode
import InvenTree.helpers
import InvenTree.ready
@@ -32,13 +34,10 @@ class LabelConfig(AppConfig):
):
return
if InvenTree.ready.isRunningMigrations():
return
if not InvenTree.ready.canAppAccessDatabase(allow_test=False):
return # pragma: no cover
if (
InvenTree.ready.canAppAccessDatabase(allow_test=False)
and not InvenTree.ready.isImportingData()
):
with maintenance_mode_on():
try:
self.create_labels() # pragma: no cover
except (
@@ -52,6 +51,8 @@ class LabelConfig(AppConfig):
'Database was not ready for creating labels', stacklevel=2
)
set_maintenance_mode(False)
def create_labels(self):
"""Create all default templates."""
# Test if models are ready