Skip to content

Commit

Permalink
Implement DB migrations for allowing changing of the culprit feature (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
florinbilt authored Nov 14, 2024
1 parent 146ec53 commit b2231d1
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Generated by Django 5.1.3 on 2024-11-14 13:30

import django.db.models.deletion
from django.db import migrations, models


def update_summary_original_push(apps, schema_editor):
PerformanceAlertSummary = apps.get_model('perf', 'PerformanceAlertSummary')
for alert in PerformanceAlertSummary.objects.all():
alert.original_push = alert.push
alert.save()


class Migration(migrations.Migration):

dependencies = [
("perf", "0055_remove_performancealerttesting_related_summary_and_more"),
]

operations = [
migrations.AddField(
model_name="performancealertsummary",
name="original_push",
field=models.ForeignKey(
default=None,
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="+",
to="model.push",
),
),
migrations.RunPython(update_summary_original_push, reverse_code=migrations.RunPython.noop),
]
7 changes: 6 additions & 1 deletion treeherder/perf/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,9 @@ class PerformanceAlertSummary(models.Model):

prev_push = models.ForeignKey(Push, on_delete=models.CASCADE, related_name="+")
push = models.ForeignKey(Push, on_delete=models.CASCADE, related_name="+")

original_push = models.ForeignKey(
Push, on_delete=models.CASCADE, related_name="+", null=True, default=None
)
manually_created = models.BooleanField(default=False)

notes = models.TextField(null=True, blank=True)
Expand Down Expand Up @@ -344,6 +346,9 @@ def save(self, *args, update_fields=None, **kwargs):
if update_fields is not None:
update_fields = {"bug_due_date"}.union(update_fields)

if not self.original_push:
self.original_push = self.push

super().save(*args, update_fields=update_fields, **kwargs)
self.__prev_bug_number = self.bug_number

Expand Down

0 comments on commit b2231d1

Please sign in to comment.