"""Add Product.title column

Revision ID: f2ddd8df0212
Revises: 02bc5b2abef8
Create Date: 2025-11-25 12:21:38.161665

"""

from collections.abc import Sequence

import sqlalchemy as sa
import sqlmodel  # noqa: F401

from alembic import op

# revision identifiers, used by Alembic.
revision: str = "f2ddd8df0212"
down_revision: str | Sequence[str] | None = "02bc5b2abef8"  # pragma: allowlist secret
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None


def upgrade() -> None:
    """Upgrade schema."""
    # Add title column as nullable initially for safe backfill
    with op.batch_alter_table("products", schema=None) as batch_op:
        batch_op.add_column(sa.Column("title", sqlmodel.sql.sqltypes.AutoString(), nullable=True))


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

    # ### end Alembic commands ###
