Skip to content

Commit

Permalink
Refine ordering and index #659
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Druez <[email protected]>
  • Loading branch information
tdruez committed Apr 18, 2023
1 parent 2954e45 commit 7c8eae8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
19 changes: 13 additions & 6 deletions scanpipe/migrations/0028_codebaserelation_and_more.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Generated by Django 4.2 on 2023-04-17 16:53
# Generated by Django 4.2 on 2023-04-18 06:33

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


class Migration(migrations.Migration):
Expand All @@ -14,12 +15,14 @@ class Migration(migrations.Migration):
name="CodebaseRelation",
fields=[
(
"id",
models.AutoField(
auto_created=True,
"uuid",
models.UUIDField(
db_index=True,
default=uuid.uuid4,
editable=False,
primary_key=True,
serialize=False,
verbose_name="ID",
verbose_name="UUID",
),
),
(
Expand All @@ -44,13 +47,17 @@ class Migration(migrations.Migration):
("match_type", models.CharField(max_length=30)),
],
options={
"ordering": ["from_resource__path"],
"ordering": ["from_resource__path", "to_resource__path"],
},
),
migrations.AlterUniqueTogether(
name="codebaseresource",
unique_together=set(),
),
migrations.AddIndex(
model_name="codebaseresource",
index=models.Index(fields=["path"], name="scanpipe_co_path_6abc6a_idx"),
),
migrations.AddIndex(
model_name="codebaseresource",
index=models.Index(fields=["name"], name="scanpipe_co_name_4da308_idx"),
Expand Down
4 changes: 3 additions & 1 deletion scanpipe/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1627,6 +1627,7 @@ class Compliance(models.TextChoices):

class Meta:
indexes = [
models.Index(fields=["path"]),
models.Index(fields=["name"]),
models.Index(fields=["extension"]),
models.Index(fields=["programming_language"]),
Expand Down Expand Up @@ -1933,6 +1934,7 @@ def as_spdx(self):


class CodebaseRelation(
UUIDPKModel,
ProjectRelatedModel,
ExtraDataFieldMixin,
models.Model,
Expand Down Expand Up @@ -1965,7 +1967,7 @@ class Relationship(models.TextChoices):
)

class Meta:
ordering = ["from_resource__path"]
ordering = ["from_resource__path", "to_resource__path"]

def __str__(self):
return (
Expand Down

0 comments on commit 7c8eae8

Please sign in to comment.