Skip to content

Commit

Permalink
Remove resolved_by_alert field from state and remove constraint (#5156)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
iskhakov and vadimkerr authored Oct 10, 2024
1 parent e569353 commit 15de078
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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'),
),
]
3 changes: 2 additions & 1 deletion engine/apps/alerts/models/alert_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 15de078

Please sign in to comment.