"""SBOM ecosystem enum expansion: add terraform, ansible, tool

Revision ID: d6e7f8a9b0c1
Revises: c5d6e7f8a9b0
Create Date: 2026-03-12 00:00:00.000000
"""
from typing import Sequence, Union

from alembic import op

revision: str = "d6e7f8a9b0c1"
down_revision: Union[str, None] = "c5d6e7f8a9b0"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    # PostgreSQL requires each ADD VALUE in its own statement and cannot be
    # run inside a transaction that also modifies data. ADD VALUE is
    # transactional in PG 12+ (no COMMIT needed).
    op.execute("ALTER TYPE ecosystem ADD VALUE IF NOT EXISTS 'terraform'")
    op.execute("ALTER TYPE ecosystem ADD VALUE IF NOT EXISTS 'ansible'")
    op.execute("ALTER TYPE ecosystem ADD VALUE IF NOT EXISTS 'tool'")


def downgrade() -> None:
    # PostgreSQL does not support removing enum values without recreating the
    # type. Document the limitation and do nothing — reverting this migration
    # requires a full type recreation if needed.
    pass
