"""loyalty 005 - add last_expiration_warning_at to loyalty_cards

Tracks when the last expiration warning email was sent to prevent
duplicate notifications. The expiration task checks this timestamp
and only sends a warning once per expiration cycle.

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

from alembic import op

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


def upgrade() -> None:
    op.add_column(
        "loyalty_cards",
        sa.Column("last_expiration_warning_at", sa.DateTime(), nullable=True),
    )


def downgrade() -> None:
    op.drop_column("loyalty_cards", "last_expiration_warning_at")
