gabriel / musehub public
0057_branch_repo_name_index.py python
39 lines 1.2 KB
Raw
sha256:3ff9c9863a9891bdcde71b4a43228f66d0493e38b7cc1d09fe9eb7de774046b2 feat: add repair-commit wire endpoint (API parity with repa… Opus 4.8 minor ⚠ breaking 1 day ago
1 """Add composite (repo_id, name) index on musehub_branches.
2
3 get_branch_head_commit_id() does a point lookup WHERE repo_id = ? AND name = ?
4 on every push and fetch. Without a composite index this scans all branches for
5 the repo. list_branches_with_detail() also benefits: the composite index covers
6 both the WHERE clause and the ORDER BY name, eliminating an in-memory sort.
7
8 Revision ID: 0057
9 Revises: 0056
10 """
11 from __future__ import annotations
12
13 from alembic import op
14
15 revision = "0057"
16 down_revision = "0056"
17 branch_labels = None
18 depends_on = None
19
20
21 def upgrade() -> None:
22 op.create_index(
23 "ix_musehub_branches_repo_name",
24 "musehub_branches",
25 ["repo_id", "name"],
26 )
27 # The composite index on (repo_id, name) makes the single-column repo_id
28 # index redundant — PostgreSQL can satisfy any repo_id-only scan using the
29 # leftmost prefix of the composite index.
30 op.drop_index("ix_musehub_branches_repo_id", table_name="musehub_branches")
31
32
33 def downgrade() -> None:
34 op.create_index(
35 "ix_musehub_branches_repo_id",
36 "musehub_branches",
37 ["repo_id"],
38 )
39 op.drop_index("ix_musehub_branches_repo_name", table_name="musehub_branches")
File History 1 commit
sha256:3ff9c9863a9891bdcde71b4a43228f66d0493e38b7cc1d09fe9eb7de774046b2 feat: add repair-commit wire endpoint (API parity with repa… Opus 4.8 minor 1 day ago