mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Migration fixes (#5025)
* Catch exception on is_worker_running - Exception may occur if table is not yet available - If it *does* then we can assume the worker is no running * General error catch in offload_task * Pick an earlier migration to run from? * Update initial common migration - Handle error on table duplication * Change target migration file - Ensure that part MPTT migrations have been applied! * Fix migration ref - Need 0025 - Price field needs to be available
This commit is contained in:
parent
89ad8312ce
commit
9117c2234b
@ -38,7 +38,14 @@ def is_worker_running(**kwargs):
|
||||
)
|
||||
|
||||
# If any results are returned, then the background worker is running!
|
||||
return results.exists()
|
||||
try:
|
||||
result = results.exists()
|
||||
except Exception:
|
||||
# We may throw an exception if the database is not ready,
|
||||
# or if the django_q table is not yet created (i.e. in CI testing)
|
||||
result = False
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def check_system_health(**kwargs):
|
||||
|
@ -186,6 +186,8 @@ def offload_task(taskname, *args, force_async=False, force_sync=False, **kwargs)
|
||||
task.run()
|
||||
except ImportError:
|
||||
raise_warning(f"WARNING: '{taskname}' not started - Function not found")
|
||||
except Exception as exc:
|
||||
raise_warning(f"WARNING: '{taskname}' not started due to {type(exc)}")
|
||||
else:
|
||||
|
||||
if callable(taskname):
|
||||
|
@ -4,15 +4,40 @@ import django.core.validators
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class CreateModelOrSkip(migrations.CreateModel):
|
||||
"""Custom migration operation to create a model if it does not already exist.
|
||||
|
||||
- If the model already exists, the migration is skipped
|
||||
- This class has been added to deal with some errors being thrown in CI tests
|
||||
- The 'common_currency' table doesn't exist anymore anyway!
|
||||
- In the future, these migrations will be squashed
|
||||
"""
|
||||
|
||||
def database_forwards(self, app_label, schema_editor, from_state, to_state) -> None:
|
||||
"""Forwards migration *attempts* to create the model, but will fail gracefully if it already exists"""
|
||||
|
||||
try:
|
||||
super().database_forwards(app_label, schema_editor, from_state, to_state)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def state_forwards(self, app_label, state) -> None:
|
||||
try:
|
||||
super().state_forwards(app_label, state)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
atomic = False
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
CreateModelOrSkip(
|
||||
name='Currency',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
|
Loading…
Reference in New Issue
Block a user