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),