Skip to content

Commit 85dd9e9

Browse files
Simoh23999arkid15r
andauthored
Indexes added to created_at Field in Issue, PullRequest, and Release Models (#1183)
* Add feature: index on created_at field in issue model * Add feature: index on created_at field in PullRequest model * Add feature: index on created_at field in Release model * Add feature: indexes on created_at in Issue, PullRequest, and Release models * Update code --------- Co-authored-by: Arkadii Yakovets <[email protected]>
1 parent 7210a4a commit 85dd9e9

File tree

4 files changed

+33
-0
lines changed

4 files changed

+33
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Generated by Django 5.1.7 on 2025-03-26 16:08
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
dependencies = [
8+
("github", "0018_alter_issue_managers_alter_pullrequest_managers"),
9+
]
10+
11+
operations = [
12+
migrations.AddIndex(
13+
model_name="issue",
14+
index=models.Index(fields=["-created_at"], name="github_issu_created_4afbcc_idx"),
15+
),
16+
migrations.AddIndex(
17+
model_name="pullrequest",
18+
index=models.Index(fields=["-created_at"], name="github_pull_created_190b3c_idx"),
19+
),
20+
migrations.AddIndex(
21+
model_name="release",
22+
index=models.Index(fields=["-created_at"], name="github_rele_created_d51966_idx"),
23+
),
24+
]

backend/apps/github/models/issue.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ class Issue(GenericIssueModel):
2121

2222
class Meta:
2323
db_table = "github_issues"
24+
indexes = [
25+
models.Index(fields=["-created_at"]),
26+
]
2427
ordering = ("-updated_at", "-state")
2528
verbose_name_plural = "Issues"
2629

backend/apps/github/models/pull_request.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ class PullRequest(GenericIssueModel):
1616

1717
class Meta:
1818
db_table = "github_pull_requests"
19+
indexes = [
20+
models.Index(fields=["-created_at"]),
21+
]
1922
ordering = ("-updated_at", "-state")
2023
verbose_name_plural = "Pull Requests"
2124

backend/apps/github/models/release.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ class Release(BulkSaveModel, NodeModel, ReleaseIndexMixin, TimestampedModel):
1212

1313
class Meta:
1414
db_table = "github_releases"
15+
indexes = [
16+
models.Index(fields=["-created_at"]),
17+
]
1518
verbose_name_plural = "Releases"
1619

1720
name = models.CharField(verbose_name="Name", max_length=200)

0 commit comments

Comments
 (0)