gabriel / musehub public
0060_commit_graph.py python
53 lines 1.5 KB
Raw
sha256:1ccb8409daa5aabe577bd26d11b56ed12f3376d64011d0e75a247e81211a66ee docs(mwp4/phase5): tick Phase 5 checkboxes, close musehub#109 Sonnet 4.6 20 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:1ccb8409daa5aabe577bd26d11b56ed12f3376d64011d0e75a247e81211a66ee docs(mwp4/phase5): tick Phase 5 checkboxes, close musehub#109 Sonnet 4.6 20 days ago
sha256:2c523da45351334b5c4dbefed4dc3dd553b3faa8737a4e6caf301e5dc82141be test(mwp4): Phase 0 RED reproduction tests for RC-4 ordering race Sonnet 4.6 20 days ago