"""hwadm007: add requires_revalidation to merchant_billing_methods.

Adds a boolean flag that signals the billing method needs to be re-verified
(e.g. after a card expiry, a failed charge, or a manual admin override) before
the next platform-fee billing cycle can proceed.

Revision ID: hwadm007_billing_revalidation
Revises: prd003_merge_all_heads
Create Date: 2026-05-13
"""
from typing import Sequence, Union

import sqlalchemy as sa
from alembic import op

revision: str = "hwadm007_billing_revalidation"
down_revision: Union[str, Sequence[str], None] = "prd003_merge_all_heads"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    op.add_column(
        "merchant_billing_methods",
        sa.Column(
            "requires_revalidation",
            sa.Boolean(),
            nullable=False,
            server_default="false",
        ),
    )


def downgrade() -> None:
    op.drop_column("merchant_billing_methods", "requires_revalidation")
