"""Clear categories again so the next collection applies the widened vocabulary

Revision ID: c3d4e5f6a7b8
Revises: b2c3d4e5f6a7
"""
from collections.abc import Sequence

from alembic import op

revision: str = "c3d4e5f6a7b8"
down_revision: str | None = "b2c3d4e5f6a7"
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None

PACKAGING = (
    "beverage can", "pet bottle", "value added pack", "magnum+", "multipack",
    "wooden box", "miscellaneous", "blended", "aperitifs", "aperitiv", "korn",
)


def upgrade() -> None:
    values = ", ".join(f"'{w}'" for w in PACKAGING)
    op.execute(f"UPDATE products SET category = NULL WHERE lower(category) IN ({values})")


def downgrade() -> None:
    pass
