"""Add intel_full_json to symbol index + file-level intel cache table. intel_full_json: full serialized IntelSnapshot stored at push time so any page that needs repo-level intel never has to load the msgpack blob or run compute_intel at request time. musehub_file_intel_cache: per-file intel cache keyed by (repo_id, file_path). The ref column stores the symbol index commit_id at which the cache was built. Rows are invalidated on push by deleting all rows for the repo. Revision ID: 0015 Revises: 0014 """ from alembic import op import sqlalchemy as sa revision = "0015" down_revision = "0014" branch_labels = None depends_on = None def upgrade() -> None: op.add_column( "musehub_symbol_index", sa.Column("intel_full_json", sa.Text(), nullable=True), ) op.create_table( "musehub_file_intel_cache", sa.Column("cache_id", sa.String(36), primary_key=True), sa.Column( "repo_id", sa.String(36), sa.ForeignKey("musehub_repos.repo_id", ondelete="CASCADE"), nullable=False, ), sa.Column("file_path", sa.String(1024), nullable=False), sa.Column("ref", sa.String(64), nullable=False), sa.Column("intel_json", sa.Text(), nullable=False), sa.Column("symbol_history_json", sa.Text(), nullable=False), sa.Column( "computed_at", sa.DateTime(timezone=True), nullable=False, ), ) op.create_index( "ix_file_intel_cache_repo_path", "musehub_file_intel_cache", ["repo_id", "file_path"], unique=True, ) op.create_index( "ix_file_intel_cache_repo_id", "musehub_file_intel_cache", ["repo_id"], ) def downgrade() -> None: op.drop_index("ix_file_intel_cache_repo_id", table_name="musehub_file_intel_cache") op.drop_index("ix_file_intel_cache_repo_path", table_name="musehub_file_intel_cache") op.drop_table("musehub_file_intel_cache") op.drop_column("musehub_symbol_index", "intel_full_json")