From 5ff58ac4d6726c083fab311a212860df18e15462 Mon Sep 17 00:00:00 2001 From: v6ole Date: Tue, 4 Aug 2026 16:15:10 +0800 Subject: [PATCH] fix: skip enum upgrade before initial schema creation --- .../migrations/versions/20260803_reliability_monitoring.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/backend/migrations/versions/20260803_reliability_monitoring.py b/backend/migrations/versions/20260803_reliability_monitoring.py index 1cd3c74..b1f9007 100644 --- a/backend/migrations/versions/20260803_reliability_monitoring.py +++ b/backend/migrations/versions/20260803_reliability_monitoring.py @@ -118,6 +118,12 @@ def _upgrade_postgresql_alert_type(connection: Connection) -> None: """Permit the degraded alert value for databases using PostgreSQL enums.""" if connection.dialect.name == "postgresql": enum_name = AlertEvent.__table__.c.alert_type.type.name + enum_exists = connection.execute( + text("SELECT 1 FROM pg_type WHERE typname = :enum_name"), + {"enum_name": enum_name}, + ).scalar_one_or_none() + if enum_exists is None: + return connection.execute( text( f"ALTER TYPE {_quote(connection, enum_name)} "