Fix account_risk_state missing on PostgreSQL: probe table before cache skip.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -443,26 +443,9 @@ def init_db():
|
||||
rollback_if_postgres(conn)
|
||||
ensure_kline_tables(conn)
|
||||
init_strategy_tables(conn)
|
||||
conn.execute(
|
||||
"""CREATE TABLE IF NOT EXISTS account_risk_state (
|
||||
id INTEGER PRIMARY KEY CHECK (id = 1),
|
||||
trading_day TEXT,
|
||||
manual_close_count INTEGER DEFAULT 0,
|
||||
cooloff_until_ms INTEGER,
|
||||
cooloff_hours INTEGER,
|
||||
daily_frozen INTEGER DEFAULT 0,
|
||||
last_close_at_ms INTEGER,
|
||||
updated_at TEXT
|
||||
)"""
|
||||
)
|
||||
if not conn.execute("SELECT id FROM account_risk_state WHERE id=1").fetchone():
|
||||
conn.execute(
|
||||
"INSERT INTO account_risk_state (id, trading_day, manual_close_count, daily_frozen) "
|
||||
"VALUES (1, '', 0, 0)"
|
||||
)
|
||||
conn.commit()
|
||||
from risk.account_risk_lib import ensure_account_risk_schema
|
||||
from recommend_store import ensure_recommend_tables
|
||||
|
||||
ensure_account_risk_schema(conn)
|
||||
ensure_recommend_tables(conn)
|
||||
from ai_messages import ensure_ai_messages_table
|
||||
|
||||
Reference in New Issue
Block a user