"""add repo_id to capability_catalog

Revision ID: p3k4l5m6n7o8
Revises: o2j3k4l5m6n7
Create Date: 2026-03-31

"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects.postgresql import UUID

revision = "p3k4l5m6n7o8"
down_revision = "o2j3k4l5m6n7"
branch_labels = None
depends_on = None


def upgrade() -> None:
    op.add_column(
        "capability_catalog",
        sa.Column("repo_id", UUID(as_uuid=True), sa.ForeignKey("managed_repos.id", ondelete="SET NULL"), nullable=True),
    )
    op.create_index("ix_capability_catalog_repo_id", "capability_catalog", ["repo_id"])


def downgrade() -> None:
    op.drop_index("ix_capability_catalog_repo_id", table_name="capability_catalog")
    op.drop_column("capability_catalog", "repo_id")
