gabriel / musehub public

0021_structured_delta_column.py file-level

at sha256:8 · View file ↗ · Intel ↗

History
1 files
1 commits
0 hotspots
0 🧊 dead
0 💥 blast risk
sha256:b Merge 'docs/security-monitoring-verified' into 'dev' — proposal: docs+i… · gabriel · Aug 29, 2026
1 """Add structured_delta column to musehub_commits.
2
3 structured_delta was stored in the dropped commit_meta JSON blob. This migration
4 adds it as a dedicated nullable JSONB column so the symbol indexer can read it
5 back without losing fidelity on historical commits. New pushes write it directly;
6 historical rows remain NULL and fall back to snapshot diffing.
7
8 Revision ID: 0021
9 Revises: 0020
10 """
11 from __future__ import annotations
12
13 from alembic import op
14 import sqlalchemy as sa
15 from sqlalchemy.dialects.postgresql import JSONB
16
17 revision = "0021"
18 down_revision = "0020"
19 branch_labels = None
20 depends_on = None
21
22
23 def upgrade() -> None:
24 op.add_column(
25 "musehub_commits",
26 sa.Column("structured_delta", JSONB(), nullable=True),
27 )
28
29
30 def downgrade() -> None:
31 from sqlalchemy import text
32 op.execute(text("ALTER TABLE musehub_commits DROP COLUMN IF EXISTS structured_delta"))