Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(project-tree): add shortcut ordering index (#60624)

posthog[bot]1b15696a0803
diff --git a/posthog/migrations/1189_file_system_shortcut_order_index.py b/posthog/migrations/1189_file_system_shortcut_order_index.py
new file mode 100644
index 000000000000..018f1dcac503
--- /dev/null
+++ b/posthog/migrations/1189_file_system_shortcut_order_index.py
@@ -0,0 +1,25 @@
+from django.contrib.postgres.operations import AddIndexConcurrently
+from django.db import migrations, models
+from django.db.models.expressions import F
+from django.db.models.functions import Lower
+
+
+class Migration(migrations.Migration):
+ atomic = False
+
+ dependencies = [
+ ("posthog", "1188_migrate_cdp_models"),
+ ]
+
+ operations = [
+ AddIndexConcurrently(
+ model_name="filesystemshortcut",
+ index=models.Index(
+ F("team_id"),
+ F("user_id"),
+ F("order"),
+ Lower("path"),
+ name="posthog_fss_t_u_ordpathlc",
+ ),
+ ),
+ ]
diff --git a/posthog/migrations/max_migration.txt b/posthog/migrations/max_migration.txt
index 61a3593fc9a4..2631b1248ae0 100644
--- a/posthog/migrations/max_migration.txt
+++ b/posthog/migrations/max_migration.txt
@@ -1 +1 @@
-1188_migrate_cdp_models
+1189_file_system_shortcut_order_index
diff --git a/posthog/models/file_system/file_system_shortcut.py b/posthog/models/file_system/file_system_shortcut.py
index 984446d1c623..525beb88f839 100644
--- a/posthog/models/file_system/file_system_shortcut.py
+++ b/posthog/models/file_system/file_system_shortcut.py
@@ -1,5 +1,6 @@
from django.db import models
from django.db.models.expressions import F
+from django.db.models.functions import Lower
from django.utils import timezone
from posthog.models.team import Team
@@ -25,6 +26,7 @@ class FileSystemShortcut(models.Model):
class Meta:
indexes = [
models.Index(fields=["team", "user"]),
+ models.Index(F("team_id"), F("user_id"), F("order"), Lower("path"), name="posthog_fss_t_u_ordpathlc"),
models.Index(F("team_id"), F("path"), name="posthog_fs_s_team_path"),
models.Index(F("team_id"), F("type"), F("ref"), name="posthog_fs_s_team_typeref"),
]