"""A router's latency may be absent Latency is now each scrape's own percentile (#5741), and a scrape in which a router answered nothing has none: those rows carry NULL rather than a made-up 0 or the old lifetime figure. Revision ID: traefik_007_latency_nullable Revises: traefik_006_status_codes Create Date: 2026-10-14 """ from typing import Sequence, Union from alembic import op revision: str = "traefik_007_latency_nullable" down_revision: Union[str, None] = "traefik_006_status_codes" branch_labels: Union[str, Sequence[str], None] = None depends_on: Union[str, Sequence[str], None] = None _COLUMNS = ("latency_p50_ms", "latency_p95_ms", "latency_p99_ms") def upgrade() -> None: for column in _COLUMNS: op.alter_column("traefik_metrics", column, nullable=True) def downgrade() -> None: for column in _COLUMNS: op.execute(f"UPDATE traefik_metrics SET {column} = 0 WHERE {column} IS NULL") op.alter_column("traefik_metrics", column, nullable=False)