Skip to content

Commit b1b6b51

Browse files
committed
feat: add series for builds table
this new field will help to search builds by series instead of compiler, config_name, and arch. It must be a MD5 field concatenating these three fields. We will generate it automatically though generated column in the DB. closes #1474 and part of #1454
1 parent 10e04b5 commit b1b6b51

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Generated by Django 5.1.10 on 2025-09-10 16:52
2+
3+
import django.db.models.functions.text
4+
from django.db import migrations, models
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
("kernelCI_app", "0002_remove_fk_constraint"),
11+
]
12+
13+
operations = [
14+
migrations.AddField(
15+
model_name="builds",
16+
name="series",
17+
field=models.GeneratedField(
18+
db_persist=True,
19+
expression=django.db.models.functions.text.MD5(
20+
django.db.models.functions.text.Concat(
21+
models.F("config_name"),
22+
models.F("compiler"),
23+
models.F("architecture"),
24+
)
25+
),
26+
output_field=models.TextField(blank=True, null=True),
27+
),
28+
),
29+
migrations.AddIndex(
30+
model_name="builds",
31+
index=models.Index(fields=["series"], name="builds_series_idx"),
32+
),
33+
]

backend/kernelCI_app/models.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from django.db import models
22
from django.contrib.postgres.fields import ArrayField
3+
from django.db.models import F
4+
from django.db.models.functions import Concat, MD5
35

46

57
class StatusChoices(models.TextChoices):
@@ -87,9 +89,23 @@ class Builds(models.Model):
8789
status = models.CharField(
8890
max_length=10, choices=StatusChoices.choices, blank=True, null=True
8991
)
92+
series = models.GeneratedField(
93+
expression=MD5(
94+
Concat(
95+
F("config_name"),
96+
F("compiler"),
97+
F("architecture"),
98+
),
99+
),
100+
output_field=models.TextField(blank=True, null=True),
101+
db_persist=True,
102+
)
90103

91104
class Meta:
92105
db_table = "builds"
106+
indexes = [
107+
models.Index(fields=["series"], name="builds_series_idx"),
108+
]
93109

94110

95111
class Tests(models.Model):

0 commit comments

Comments
 (0)