perf(db): add targeted composite indexes
This commit is contained in:
@@ -0,0 +1,21 @@
|
|||||||
|
# Generated by Django 5.2.12 on 2026-04-30 12:23
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('clients', '0001_initial'),
|
||||||
|
('projects', '0002_remove_projectmembership'),
|
||||||
|
('workspaces', '0007_workspacemembership_membership_ws_active_user_idx'),
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name='project',
|
||||||
|
index=models.Index(fields=['workspace', 'is_archived', 'updated_at'], name='project_ws_arch_upd_idx'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -37,6 +37,7 @@ class Project(BaseModel):
|
|||||||
ordering = ("-updated_at", "-created_at")
|
ordering = ("-updated_at", "-created_at")
|
||||||
indexes = [
|
indexes = [
|
||||||
models.Index(fields=["workspace"], name="project_workspace_idx"),
|
models.Index(fields=["workspace"], name="project_workspace_idx"),
|
||||||
|
models.Index(fields=["workspace", "is_archived", "updated_at"], name="project_ws_arch_upd_idx"),
|
||||||
]
|
]
|
||||||
constraints = [
|
constraints = [
|
||||||
models.UniqueConstraint(
|
models.UniqueConstraint(
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
# Generated by Django 5.2.12 on 2026-04-30 12:23
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('projects', '0003_project_project_ws_arch_upd_idx'),
|
||||||
|
('tags', '0001_initial'),
|
||||||
|
('time_entries', '0001_initial'),
|
||||||
|
('workspaces', '0007_workspacemembership_membership_ws_active_user_idx'),
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name='timeentry',
|
||||||
|
index=models.Index(fields=['workspace', 'user', 'start_time'], name='time_entry_ws_user_start_idx'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -56,13 +56,14 @@ class TimeEntry(BaseModel):
|
|||||||
class Meta:
|
class Meta:
|
||||||
db_table = "time_entry"
|
db_table = "time_entry"
|
||||||
ordering = ("-updated_at", "-created_at")
|
ordering = ("-updated_at", "-created_at")
|
||||||
indexes = [
|
indexes = [
|
||||||
models.Index(fields=["workspace"], name="time_entry_workspace_idx"),
|
models.Index(fields=["workspace"], name="time_entry_workspace_idx"),
|
||||||
models.Index(fields=["user"], name="time_entry_user_idx"),
|
models.Index(fields=["user"], name="time_entry_user_idx"),
|
||||||
models.Index(fields=["project"], name="time_entry_project_idx"),
|
models.Index(fields=["project"], name="time_entry_project_idx"),
|
||||||
models.Index(fields=["start_time"], name="time_entry_start_idx"),
|
models.Index(fields=["start_time"], name="time_entry_start_idx"),
|
||||||
models.Index(fields=["workspace", "start_time"], name="time_entry_workspace_start_idx"),
|
models.Index(fields=["workspace", "start_time"], name="time_entry_workspace_start_idx"),
|
||||||
]
|
models.Index(fields=["workspace", "user", "start_time"], name="time_entry_ws_user_start_idx"),
|
||||||
|
]
|
||||||
constraints = [
|
constraints = [
|
||||||
models.UniqueConstraint(
|
models.UniqueConstraint(
|
||||||
fields=["workspace", "user"],
|
fields=["workspace", "user"],
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
# Generated by Django 5.2.12 on 2026-04-30 12:23
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('workspaces', '0006_workspace_thumbnail'),
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name='workspacemembership',
|
||||||
|
index=models.Index(fields=['workspace', 'is_active', 'user'], name='membership_ws_active_user_idx'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -80,6 +80,7 @@ class WorkspaceMembership(BaseModel):
|
|||||||
indexes = [
|
indexes = [
|
||||||
models.Index(fields=["workspace"], name="membership_workspace_idx"),
|
models.Index(fields=["workspace"], name="membership_workspace_idx"),
|
||||||
models.Index(fields=["user"], name="membership_user_idx"),
|
models.Index(fields=["user"], name="membership_user_idx"),
|
||||||
|
models.Index(fields=["workspace", "is_active", "user"], name="membership_ws_active_user_idx"),
|
||||||
]
|
]
|
||||||
constraints = [
|
constraints = [
|
||||||
models.UniqueConstraint(
|
models.UniqueConstraint(
|
||||||
|
|||||||
Reference in New Issue
Block a user