Ensure account_risk_state table exists even if schema flag was set.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-01 08:25:07 +08:00
parent ef790c8a80
commit 06fbff04a7
+9 -1
View File
@@ -119,7 +119,15 @@ def _db_retry(action: Callable[[], T], *, retries: int = 8, base_delay: float =
def ensure_account_risk_schema(conn) -> None: def ensure_account_risk_schema(conn) -> None:
global _SCHEMA_READY global _SCHEMA_READY
if _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( conn.execute(
"""CREATE TABLE IF NOT EXISTS account_risk_state ( """CREATE TABLE IF NOT EXISTS account_risk_state (
id INTEGER PRIMARY KEY CHECK (id = 1), id INTEGER PRIMARY KEY CHECK (id = 1),