fix alert_severity on check_result defaulting to warning

This commit is contained in:
sadnub 2022-04-15 17:29:31 -04:00
parent b1301091f9
commit d23d641b1b
3 changed files with 28 additions and 3 deletions

View File

@ -26,12 +26,16 @@ def migrate_check_results(apps, schema_editor):
retcode=check.retcode,
execution_time=check.execution_time,
history=check.history,
alert_severity=check.alert_severity
if check.check_type
in ["cpuload", "memory", "diskspace", "script"]
else None,
)
else:
CheckResult.objects.create(
assigned_check=check,
agent=check.agent,
assigned_check_id=check.id,
agent_id=check.agent.id,
status=check.status,
more_info=check.more_info,
last_run=check.last_run,
@ -43,6 +47,10 @@ def migrate_check_results(apps, schema_editor):
retcode=check.retcode,
execution_time=check.execution_time,
history=check.history,
alert_severity=check.alert_severity
if check.check_type
in ["cpuload", "memory", "diskspace", "script"]
else None,
)
except IntegrityError:
pass

View File

@ -0,0 +1,18 @@
# Generated by Django 4.0.3 on 2022-04-15 21:23
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('checks', '0028_auto_20220401_2301'),
]
operations = [
migrations.AlterField(
model_name='checkresult',
name='alert_severity',
field=models.CharField(blank=True, choices=[('info', 'Informational'), ('warning', 'Warning'), ('error', 'Error')], max_length=15, null=True),
),
]

View File

@ -382,7 +382,6 @@ class CheckResult(models.Model):
alert_severity = models.CharField(
max_length=15,
choices=SEVERITY_CHOICES,
default="warning",
null=True,
blank=True,
)