"""add segment_id to api_calls

Revision ID: bda1ff338ff3
Revises: 96f747fa47d5
Create Date: 2026-04-06 14:32:51.054855

"""

from collections.abc import Sequence

import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
revision: str = "bda1ff338ff3"
down_revision: str | Sequence[str] | None = "96f747fa47d5"
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None


def upgrade() -> None:
    """Upgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table("api_calls", schema=None) as batch_op:
        batch_op.add_column(sa.Column("segment_id", sa.String(length=20), nullable=True))
        batch_op.create_index(batch_op.f("ix_api_calls_segment_id"), ["segment_id"], unique=False)

    # ### end Alembic commands ###


def downgrade() -> None:
    """Downgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table("api_calls", schema=None) as batch_op:
        batch_op.drop_index(batch_op.f("ix_api_calls_segment_id"))
        batch_op.drop_column("segment_id")

    # ### end Alembic commands ###
