Remove resolved_by_alert field from state and remove constraint (#5156)

Removes resolved_by_alert field from Django state only. It will still be
in db, since it's to expensive to delete it in prod.
We remove this field to get rid of ON_DELETE=SET_NULL which causes
terrible load from SQL queries.
On top of that, we are removing FK to disable referral integrity checks,
so alert updates will work.

---------

Co-authored-by: Vadim Stepanov <vadimkerr@gmail.com>
This commit is contained in:
Ildar Iskhakov 2024-10-10 19:15:42 +08:00 committed by GitHub
parent e5693531d2
commit 4957851740
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 21 additions and 1 deletions

View file

@ -0,0 +1,19 @@
# Generated by Django 4.2.15 on 2024-10-10 11:02
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('alerts', '0060_relatedincident'),
]
operations = [
migrations.AlterField(
model_name='alertgroup',
name='resolved_by_alert',
field=models.ForeignKey(db_constraint=False, default=None, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='resolved_alert_groups', to='alerts.alert'),
),
]

View file

@ -289,7 +289,8 @@ class AlertGroup(AlertGroupSlackRenderingMixin, EscalationSnapshotMixin, models.
resolved_by_alert = models.ForeignKey(
"alerts.Alert",
on_delete=models.SET_NULL,
on_delete=models.DO_NOTHING,
db_constraint=False,
null=True,
default=None,
related_name="resolved_alert_groups",