Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Generated manually for chore/django-admin-contract-list-usability
#
# Adds standalone indexes on TrackedContract.name and TrackedContract.created_at
# to support efficient ORDER BY in the Django Admin list view at 100+ contracts.
# Both operations are index-only adds — fully reversible with no data loss.

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("ingest", "0038_dependencyimpactassessment_organizationbudget_and_more"),
]

operations = [
# Index on `name` — admin list is sortable by name; CharField ORDER BY
# hits a seq scan without this at 100+ rows.
migrations.AlterField(
model_name="trackedcontract",
name="name",
field=models.CharField(
db_index=True,
max_length=100,
help_text="Human-readable contract name",
),
),
# Index on `created_at` — the default admin ordering is ["-created_at",
# "name"], so every page load without a filter sorts by this column.
# The existing composite indexes (contract_id+is_active, network+is_active)
# do NOT cover a plain ORDER BY created_at.
migrations.AlterField(
model_name="trackedcontract",
name="created_at",
field=models.DateTimeField(
auto_now_add=True,
db_index=True,
),
),
]
4 changes: 2 additions & 2 deletions django-backend/soroscan/ingest/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ class Network(models.TextChoices):
db_index=True,
help_text="Stellar contract address (C...)",
)
name = models.CharField(max_length=100, help_text="Human-readable contract name")
name = models.CharField(max_length=100, db_index=True, help_text="Human-readable contract name")
alias = models.CharField(
max_length=256,
blank=True,
Expand Down Expand Up @@ -371,7 +371,7 @@ class Network(models.TextChoices):
help_text="Custom attributes for storing contract metadata (team, owner, cost center, etc.)",
)

created_at = models.DateTimeField(auto_now_add=True)
created_at = models.DateTimeField(auto_now_add=True, db_index=True)
updated_at = models.DateTimeField(auto_now=True)

class Meta:
Expand Down
Loading