"""Widen sync record_id for composite keys (period_recipes uuid:uuid)."""

from __future__ import annotations

from alembic import op
import sqlalchemy as sa

revision = "20260716_0010"
down_revision = "20260716_0009"
branch_labels = None
depends_on = None

_TABLES = ("sync_outbox", "sync_event_log", "sync_record_state", "sync_conflicts")


def upgrade() -> None:
    for table in _TABLES:
        op.alter_column(
            table,
            "record_id",
            existing_type=sa.String(length=64),
            type_=sa.String(length=128),
            existing_nullable=False,
        )


def downgrade() -> None:
    for table in reversed(_TABLES):
        op.alter_column(
            table,
            "record_id",
            existing_type=sa.String(length=128),
            type_=sa.String(length=64),
            existing_nullable=False,
        )
