Fix account_risk_state missing on PostgreSQL: probe table before cache skip.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-01 08:29:46 +08:00
parent d7ea7b9e8a
commit cd636ff1c3
4 changed files with 87 additions and 46 deletions
+31
View File
@@ -0,0 +1,31 @@
#!/usr/bin/env python3
"""Ensure account_risk_state exists (PostgreSQL hotfix)."""
from __future__ import annotations
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
if str(ROOT) not in sys.path:
sys.path.insert(0, str(ROOT))
from dotenv import load_dotenv
load_dotenv(ROOT / ".env")
from db_conn import connect_db, database_label # noqa: E402
from risk.account_risk_lib import ( # noqa: E402
_SCHEMA_READY,
ensure_account_risk_schema,
)
import risk.account_risk_lib as risk_mod
risk_mod._SCHEMA_READY = False
conn = connect_db()
try:
ensure_account_risk_schema(conn)
row = conn.execute("SELECT * FROM account_risk_state WHERE id=1").fetchone()
print("OK", database_label(), "row=", dict(row) if row else None)
finally:
conn.close()