"""add_evidence_team_and_notes

Revision ID: b002evidteam
Revises: b001add0test
Create Date: 2026-02-09 10:01:00.000000

"""
from typing import Sequence, Union

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


# revision identifiers, used by Alembic.
revision: str = 'b002evidteam'
down_revision: Union[str, Sequence[str], None] = 'b001add0test'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    """Create teamside enum and add team/notes columns to evidences."""
    # Create the new enum type
    teamside_enum = postgresql.ENUM('red', 'blue', name='teamside', create_type=False)
    op.execute("CREATE TYPE teamside AS ENUM ('red', 'blue')")

    # Add columns
    op.add_column('evidences', sa.Column(
        'team',
        teamside_enum,
        nullable=False,
        server_default='red',
    ))
    op.add_column('evidences', sa.Column(
        'notes',
        sa.Text(),
        nullable=True,
    ))


def downgrade() -> None:
    """Remove team/notes columns and drop teamside enum."""
    op.drop_column('evidences', 'notes')
    op.drop_column('evidences', 'team')
    op.execute("DROP TYPE IF EXISTS teamside")
