gabriel / musehub public
0019_commit_provenance_columns.py python
53 lines 1.5 KB
Raw
sha256:8e05daa29ba6702b4a2380a16d690ba31cc099d69c5c859bc6e6f16a0e945f99 Merge 'fix/deploy-memory-limits-and-log-group' into 'dev' —… Human 8 days ago
1 """Promote agent_id, model_id, commit_branch to first-class columns on musehub_commits.
2
3 These were previously buried in the commit_meta JSON blob, making them
4 unqueryable without JSON extraction. Promoting them enables indexed lookups
5 and clean UI display.
6
7 Revision ID: 0019
8 Revises: 0018
9 Create Date: 2026-05-04
10 """
11 from __future__ import annotations
12
13 from alembic import op
14 import sqlalchemy as sa
15
16 revision = "0019"
17 down_revision = "0018"
18 branch_labels = None
19 depends_on = None
20
21
22 def upgrade() -> None:
23 op.add_column(
24 "musehub_commits",
25 sa.Column("agent_id", sa.String(255), nullable=True, server_default=""),
26 )
27 op.add_column(
28 "musehub_commits",
29 sa.Column("model_id", sa.String(255), nullable=True, server_default=""),
30 )
31 op.add_column(
32 "musehub_commits",
33 sa.Column("commit_branch", sa.String(255), nullable=True),
34 )
35 # Backfill from commit_meta JSON for all existing rows
36 op.execute(
37 """
38 UPDATE musehub_commits
39 SET
40 agent_id = COALESCE(commit_meta->>'agent_id', ''),
41 model_id = COALESCE(commit_meta->>'model_id', ''),
42 commit_branch = NULLIF(commit_meta->>'branch', '')
43 WHERE agent_id IS NULL OR agent_id = ''
44 OR model_id IS NULL OR model_id = ''
45 OR commit_branch IS NULL
46 """
47 )
48
49
50 def downgrade() -> None:
51 from sqlalchemy import text
52 for col in ("commit_branch", "model_id", "agent_id"):
53 op.execute(text(f"ALTER TABLE musehub_commits DROP COLUMN IF EXISTS {col}"))
File History 3 commits
sha256:8e05daa29ba6702b4a2380a16d690ba31cc099d69c5c859bc6e6f16a0e945f99 Merge 'fix/deploy-memory-limits-and-log-group' into 'dev' —… Human 8 days ago
sha256:3fadb0439bba9451b89229676971c0d4a40900dec7810e9d5f8791b8d950d505 fix: install.sh version from latest published tarball, not … Sonnet 4.6 minor 100 days ago
sha256:763eb2cb8675073b84c19345b27586d2ed939a9aee97c5479b69f502f1a70eff fix(tests): update test suite to match current implementation Sonnet 4.6 patch 121 days ago