fix(prometheus): the migration removing sign-in targets runs on a new database, where the metric tables may not exist yet (#6747)
CI / lint (push) Successful in 2s
CI / unit (push) Successful in 1m38s
CI / integration (push) Successful in 1m57s
CI / publish (push) Successful in 1m15s

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-01 14:24:00 -05:00
co-authored by Claude Opus 5.5
parent f7a856cb90
commit ee9913b6d0
@@ -17,7 +17,9 @@ depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None: def upgrade() -> None:
# Left in place, such a target would ask with no token, and some services ban # Left in place, such a target would ask with no token, and some services ban
# an address for that. Its newest values go with it; history ages out. # an address for that. Its newest values go with it; history ages out. On a new
# database the metric tables may not exist yet, and there is nothing to remove.
if sa.inspect(op.get_bind()).has_table("plugin_metric_latest"):
op.execute(""" op.execute("""
DELETE FROM plugin_metric_latest l USING prometheus_targets t DELETE FROM plugin_metric_latest l USING prometheus_targets t
WHERE t.token_from IS NOT NULL AND l.source_module = 'prometheus' WHERE t.token_from IS NOT NULL AND l.source_module = 'prometheus'