From 06fbff04a75ec76b2c3db65963d5bcd899ca2531 Mon Sep 17 00:00:00 2001 From: dekun Date: Wed, 1 Jul 2026 08:25:07 +0800 Subject: [PATCH] Ensure account_risk_state table exists even if schema flag was set. Co-authored-by: Cursor --- risk/account_risk_lib.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/risk/account_risk_lib.py b/risk/account_risk_lib.py index 74d3a62..05d6094 100644 --- a/risk/account_risk_lib.py +++ b/risk/account_risk_lib.py @@ -119,7 +119,15 @@ def _db_retry(action: Callable[[], T], *, retries: int = 8, base_delay: float = def ensure_account_risk_schema(conn) -> None: global _SCHEMA_READY if _SCHEMA_READY: - return + try: + row = conn.execute( + "SELECT to_regclass('public.account_risk_state') AS reg" + ).fetchone() + if row and row["reg"]: + return + except Exception: + pass + _SCHEMA_READY = False conn.execute( """CREATE TABLE IF NOT EXISTS account_risk_state ( id INTEGER PRIMARY KEY CHECK (id = 1),