0019_commit_provenance_columns.py
python
sha256:f99af7b1a7f36c4d537d1c630d4b71fc39222b1255f82e930929e2fc89015e11
fix: relax browse_repo perf budget to 500ms — 200ms was too…
Sonnet 4.6
102 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 | op.drop_column("musehub_commits", "commit_branch") |
| 52 | op.drop_column("musehub_commits", "model_id") |
| 53 | op.drop_column("musehub_commits", "agent_id") |
File History
2 commits
sha256:f99af7b1a7f36c4d537d1c630d4b71fc39222b1255f82e930929e2fc89015e11
fix: relax browse_repo perf budget to 500ms — 200ms was too…
Sonnet 4.6
102 days ago
sha256:763eb2cb8675073b84c19345b27586d2ed939a9aee97c5479b69f502f1a70eff
fix(tests): update test suite to match current implementation
Sonnet 4.6
patch
124 days ago