This commit is contained in:
Valentin Rigal 2023-08-28 13:30:55 +02:00 коммит произвёл Sebastian Hengst
Родитель 1e1a750e89
Коммит ec51ddaae7
2 изменённых файлов: 27 добавлений и 43 удалений

Просмотреть файл

@ -40,49 +40,30 @@ if settings.DATABASES['default']['ENGINE'] == 'django.db.backends.mysql':
'DROP INDEX failure_line_signature_test_idx ON failure_line;',
],
state_operations=[
migrations.AddIndex(
model_name='failureline',
index=django.contrib.postgres.indexes.HashIndex(
fields=['test', 'subtest', 'status', 'expected', 'created'],
name='failure_lin_test_52689e_hash',
),
),
migrations.AddIndex(
model_name='failureline',
index=django.contrib.postgres.indexes.HashIndex(
fields=['signature', 'test', 'created'],
name='failure_lin_signatu_69323a_hash',
),
),
migrations.AddIndex(
model_name='failureline',
index=models.Index(
fields=['job_guid', 'repository'], name='failure_lin_job_gui_b67c6d_idx'
migrations.AlterIndexTogether(
name='failureline',
index_together=set(
[
('test', 'subtest', 'status', 'expected', 'created'),
('job_guid', 'repository'),
('signature', 'test', 'created'),
]
),
),
],
),
]
else:
# On postgres we can use standard migrations
EXTRA_MIGRATIONS = [
migrations.AddIndex(
model_name='failureline',
index=django.contrib.postgres.indexes.HashIndex(
fields=['test', 'subtest', 'status', 'expected', 'created'],
name='failure_lin_test_52689e_hash',
),
),
migrations.AddIndex(
model_name='failureline',
index=django.contrib.postgres.indexes.HashIndex(
fields=['signature', 'test', 'created'],
name='failure_lin_signatu_69323a_hash',
),
),
migrations.AddIndex(
model_name='failureline',
index=models.Index(
fields=['job_guid', 'repository'], name='failure_lin_job_gui_b67c6d_idx'
migrations.AlterIndexTogether(
name='failureline',
index_together=set(
[
('test', 'subtest', 'status', 'expected', 'created'),
('job_guid', 'repository'),
('signature', 'test', 'created'),
]
),
),
migrations.AddIndex(
@ -1038,6 +1019,10 @@ class Migration(migrations.Migration):
name='failureline',
unique_together=set([('job_log', 'line')]),
),
migrations.AlterIndexTogether(
name='failureline',
index_together=set([('job_guid', 'repository')]),
),
migrations.AlterUniqueTogether(
name='commit',
unique_together=set([('push', 'revision')]),

Просмотреть файл

@ -14,7 +14,6 @@ import newrelic.agent
from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.postgres.search import SearchQuery, SearchRank, SearchVector
from django.contrib.postgres.indexes import HashIndex
from django.core.cache import cache
from django.core.exceptions import ObjectDoesNotExist
from django.core.validators import MinLengthValidator
@ -956,12 +955,12 @@ class FailureLine(models.Model):
class Meta:
db_table = 'failure_line'
indexes = (
# Hash function is required to index large entries in test and subtest fields
# https://www.postgresql.org/docs/15/textsearch-limitations.html
HashIndex(fields=('test', 'subtest', 'status', 'expected', 'created')),
HashIndex(fields=('signature', 'test', 'created')),
models.Index(fields=('job_guid', 'repository')),
index_together = (
('job_guid', 'repository'),
# Prefix index: test(50), subtest(25), status, expected, created
('test', 'subtest', 'status', 'expected', 'created'),
# Prefix index: signature(25), test(50), created
('signature', 'test', 'created'),
)
unique_together = ('job_log', 'line')