"""loyalty 006 - add terms_cms_page_slug to loyalty_programs

Allows linking a loyalty program's T&C to a CMS page instead of
using the simple terms_text field. When set, the enrollment page
resolves the slug to a full CMS page. The legacy terms_text is
kept as a fallback for existing programs.

Revision ID: loyalty_006
Revises: loyalty_005
Create Date: 2026-04-11
"""
import sqlalchemy as sa

from alembic import op

revision = "loyalty_006"
down_revision = "loyalty_005"
branch_labels = None
depends_on = None


def upgrade() -> None:
    op.add_column(
        "loyalty_programs",
        sa.Column(
            "terms_cms_page_slug",
            sa.String(200),
            nullable=True,
            comment="CMS page slug for full T&C content (overrides terms_text when set)",
        ),
    )


def downgrade() -> None:
    op.drop_column("loyalty_programs", "terms_cms_page_slug")
