"""Traefik's last good config reload is a moment; routers are graded on a window - traefik_config_last_reload_success is the Unix time of the last successful reload. It was stored as a float and read as 1.0 = success, so the page said "Reload failed" on every scrape (#5355). The column becomes the moment; the old values were timestamps misread, so they go with it. - Routers are now graded on their last 15 minutes (routes.recent_window), which reads the 4xx share too: the covering router index carries it, so that read stays index-only. Revision ID: traefik_005_reload_at Revises: traefik_004_covering_indexes Create Date: 2026-10-08 """ from typing import Sequence, Union from alembic import op import sqlalchemy as sa revision: str = "traefik_005_reload_at" down_revision: Union[str, None] = "traefik_004_covering_indexes" branch_labels: Union[str, Sequence[str], None] = None depends_on: Union[str, Sequence[str], None] = None _CHARTED = ["request_rate", "latency_p95_ms", "error_rate_5xx_pct"] def upgrade() -> None: op.drop_column("traefik_global_stats", "config_last_reload_success") op.add_column("traefik_global_stats", sa.Column("config_last_reload_at", sa.DateTime(timezone=True), nullable=True)) op.drop_index("ix_traefik_metrics_router_scraped", "traefik_metrics") op.create_index("ix_traefik_metrics_router_scraped", "traefik_metrics", ["router_name", "scraped_at"], postgresql_include=_CHARTED + ["error_rate_4xx_pct"]) def downgrade() -> None: op.drop_index("ix_traefik_metrics_router_scraped", "traefik_metrics") op.create_index("ix_traefik_metrics_router_scraped", "traefik_metrics", ["router_name", "scraped_at"], postgresql_include=_CHARTED) op.drop_column("traefik_global_stats", "config_last_reload_at") op.add_column("traefik_global_stats", sa.Column("config_last_reload_success", sa.Float, nullable=True))