gabriel / musehub public
0031_symbol_vitals_coupling_history_cols.py python
68 lines 2.9 KB
Raw
sha256:a34090cc4a394a78bd72cbbe34b08cc59525141e19135b6c0ab154f10611b9ef debug(push/stream): instrument O-frame decode path with INF… Sonnet 4.6 patch 121 days ago
1 """Add symbol vitals + coupling tables; add message/commit_branch to history entries.
2
3 Pre-computes coupling and symbol vitals at push time so the symbol detail
4 page is a set of simple indexed reads instead of expensive aggregations.
5
6 New tables:
7 musehub_symbol_vitals — first_introduced, change_count, version_count, op breakdown
8 musehub_symbol_coupling — (address, co_address, shared_commits)
9
10 New columns on musehub_symbol_history_entries:
11 message — commit message (denormalized from musehub_commits)
12 commit_branch — branch the commit landed on
13
14 Revision ID: 0031
15 Revises: 0030
16 """
17 from __future__ import annotations
18
19 from alembic import op
20 import sqlalchemy as sa
21
22 revision = "0031"
23 down_revision = "0030"
24 branch_labels = None
25 depends_on = None
26
27
28 def upgrade() -> None:
29 op.add_column(
30 "musehub_symbol_history_entries",
31 sa.Column("message", sa.Text, nullable=True),
32 )
33 op.add_column(
34 "musehub_symbol_history_entries",
35 sa.Column("commit_branch", sa.String(512), nullable=True),
36 )
37
38 op.create_table(
39 "musehub_symbol_vitals",
40 sa.Column("repo_id", sa.String(128), sa.ForeignKey("musehub_repos.repo_id", ondelete="CASCADE"), primary_key=True, nullable=False),
41 sa.Column("address", sa.String(512), primary_key=True, nullable=False),
42 sa.Column("first_introduced", sa.DateTime(timezone=True), nullable=True),
43 sa.Column("change_count", sa.Integer, nullable=False, server_default="0"),
44 sa.Column("version_count", sa.Integer, nullable=False, server_default="0"),
45 sa.Column("op_add", sa.Integer, nullable=False, server_default="0"),
46 sa.Column("op_modify", sa.Integer, nullable=False, server_default="0"),
47 sa.Column("op_delete", sa.Integer, nullable=False, server_default="0"),
48 sa.Column("op_move", sa.Integer, nullable=False, server_default="0"),
49 )
50 op.create_index("ix_symbol_vitals_repo", "musehub_symbol_vitals", ["repo_id"])
51
52 op.create_table(
53 "musehub_symbol_coupling",
54 sa.Column("repo_id", sa.String(128), sa.ForeignKey("musehub_repos.repo_id", ondelete="CASCADE"), primary_key=True, nullable=False),
55 sa.Column("address", sa.String(512), primary_key=True, nullable=False),
56 sa.Column("co_address", sa.String(512), primary_key=True, nullable=False),
57 sa.Column("shared_commits", sa.Integer, nullable=False, server_default="0"),
58 )
59 op.create_index("ix_symbol_coupling_repo_address", "musehub_symbol_coupling", ["repo_id", "address"])
60
61
62 def downgrade() -> None:
63 op.drop_index("ix_symbol_coupling_repo_address", table_name="musehub_symbol_coupling")
64 op.drop_table("musehub_symbol_coupling")
65 op.drop_index("ix_symbol_vitals_repo", table_name="musehub_symbol_vitals")
66 op.drop_table("musehub_symbol_vitals")
67 op.drop_column("musehub_symbol_history_entries", "commit_branch")
68 op.drop_column("musehub_symbol_history_entries", "message")
File History 1 commit
sha256:a34090cc4a394a78bd72cbbe34b08cc59525141e19135b6c0ab154f10611b9ef debug(push/stream): instrument O-frame decode path with INF… Sonnet 4.6 patch 121 days ago