gabriel / musehub public
0060_commit_graph.py python
53 lines 1.5 KB
Raw
sha256:969ddc5e88776e70af33c016b8777bb721356508ae5f304b3fb46c451494ece7 test(mwp3): Phase 4 — fix adjacent suite regressions, lock … Sonnet 4.6 23 days ago
1 """Add musehub_commit_graph — precomputed reachability for O(frontier) DAG walks.
2
3 Issue #63 Phase 2: commit graph enables _walk_commit_delta to query in bulk
4 per BFS frontier instead of one DB call per commit.
5 """
6
7 from __future__ import annotations
8
9 import sqlalchemy as sa
10 from alembic import op
11
12 revision = "0060"
13 down_revision = "0059"
14 branch_labels = None
15 depends_on = None
16
17
18 def upgrade() -> None:
19 op.create_table(
20 "musehub_commit_graph",
21 sa.Column("repo_id", sa.String(128), nullable=False),
22 sa.Column("commit_id", sa.String(128), nullable=False),
23 sa.Column(
24 "parent_ids",
25 sa.ARRAY(sa.Text),
26 nullable=False,
27 server_default="{}",
28 ),
29 sa.Column("generation", sa.BigInteger, nullable=False, server_default="0"),
30 sa.Column("snapshot_id", sa.String(128), nullable=True),
31 sa.Column(
32 "created_at",
33 sa.DateTime(timezone=True),
34 nullable=False,
35 server_default=sa.text("now()"),
36 ),
37 sa.ForeignKeyConstraint(
38 ["repo_id"],
39 ["musehub_repos.repo_id"],
40 ondelete="CASCADE",
41 ),
42 sa.PrimaryKeyConstraint("repo_id", "commit_id"),
43 )
44 op.create_index(
45 "ix_musehub_commit_graph_repo_generation",
46 "musehub_commit_graph",
47 ["repo_id", "generation"],
48 )
49
50
51 def downgrade() -> None:
52 op.drop_index("ix_musehub_commit_graph_repo_generation", table_name="musehub_commit_graph")
53 op.drop_table("musehub_commit_graph")
File History 2 commits
sha256:969ddc5e88776e70af33c016b8777bb721356508ae5f304b3fb46c451494ece7 test(mwp3): Phase 4 — fix adjacent suite regressions, lock … Sonnet 4.6 23 days ago
sha256:1749b9cc5cd2583c56d3261c4c00a342c27435f3946d4bc3e70f76aa2795458a docs(mwp-3): TDD implementation plan for job-enqueue idempo… Opus 4.8 23 days ago