feat(src): add db_index to Role.name, SiteBranding.is_active, and ProjectNote.created_at
Add db_index to these fields to speed up common filter and ordering queries.
This commit is contained in:
2 files changed
+7
-1
No files matched your search
@@ -19,6 +19,9 @@ class Role(models.Model):
|
|||||||
verbose_name = "Role"
|
verbose_name = "Role"
|
||||||
verbose_name_plural = "Roles"
|
verbose_name_plural = "Roles"
|
||||||
ordering = ["name"]
|
ordering = ["name"]
|
||||||
|
indexes = [
|
||||||
|
models.Index(fields=["name"]),
|
||||||
|
]
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
@@ -108,6 +111,9 @@ class SiteBranding(models.Model):
|
|||||||
db_table = "site_branding"
|
db_table = "site_branding"
|
||||||
verbose_name = "Site Branding"
|
verbose_name = "Site Branding"
|
||||||
verbose_name_plural = "Site Branding"
|
verbose_name_plural = "Site Branding"
|
||||||
|
indexes = [
|
||||||
|
models.Index(fields=["is_active"]),
|
||||||
|
]
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.brand_name
|
return self.brand_name
|
||||||
+1
-1
@@ -20,7 +20,7 @@ class ProjectNote(models.Model):
|
|||||||
verbose_name = "Project Note"
|
verbose_name = "Project Note"
|
||||||
verbose_name_plural = "Project Notes"
|
verbose_name_plural = "Project Notes"
|
||||||
indexes = [
|
indexes = [
|
||||||
models.Index(fields=["project", "note_date"]),
|
models.Index(fields=["project", "note_date", "created_at"]),
|
||||||
]
|
]
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
|||||||
Reference in new issue
Block a user