"""v4 second_brain: sources.transcript_segments JSONB Revision ID: d4a72f51c8e3 Revises: c8f1d9e34b7a Create Date: 2026-05-25 13:00:00.000000 Adds a JSONB column to `sources` for the tower-side worker to persist segment-level transcription output (start/end/text per segment + word- level timing when faster-whisper returns it). Additive: `transcript_text` remains the canonical full-text the extractor consumes; this column is a secondary index for future use (chunked retrieval, timestamp-anchored quoting, etc.). JSONB rather than JSON so equality/containment ops are indexable later without a re-migration. No index added yet — Travis flagged "no gold-plating" and the column may sit unused for a while. Same lovebug-no-CREATE-on-petalbrain guard as the prior migrations: env.py has already bootstrapped the schema, this just SETs search_path and emits DDL inside it. """ from __future__ import annotations from collections.abc import Sequence from alembic import op revision: str = "d4a72f51c8e3" down_revision: str | Sequence[str] | None = "c8f1d9e34b7a" branch_labels: str | Sequence[str] | None = None depends_on: str | Sequence[str] | None = None def upgrade() -> None: op.execute("SET search_path TO second_brain") op.execute("ALTER TABLE sources ADD COLUMN transcript_segments JSONB") def downgrade() -> None: op.execute("SET search_path TO second_brain") op.execute("ALTER TABLE sources DROP COLUMN IF EXISTS transcript_segments")