Fix PostgreSQL schema init: commit DDL before ALTER migrations.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -325,6 +325,7 @@ def init_db():
|
||||
trigger_price REAL, stop_loss REAL, take_profit REAL,
|
||||
result TEXT,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP)''')
|
||||
conn.commit()
|
||||
migrations = [
|
||||
"ALTER TABLE key_monitors ADD COLUMN symbol_name TEXT",
|
||||
"ALTER TABLE key_monitors ADD COLUMN upper_triggered INTEGER DEFAULT 0",
|
||||
@@ -376,6 +377,7 @@ def init_db():
|
||||
if not is_schema_migration_error(exc):
|
||||
raise
|
||||
rollback_if_postgres(conn)
|
||||
conn.commit()
|
||||
c.execute('''CREATE TABLE IF NOT EXISTS review_records
|
||||
(id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
open_time TEXT, close_time TEXT,
|
||||
@@ -422,6 +424,7 @@ def init_db():
|
||||
(key TEXT PRIMARY KEY,
|
||||
data_json TEXT NOT NULL,
|
||||
updated_at TEXT NOT NULL)''')
|
||||
conn.commit()
|
||||
for sql in (
|
||||
"ALTER TABLE fee_rates ADD COLUMN source TEXT DEFAULT 'local'",
|
||||
):
|
||||
|
||||
@@ -149,6 +149,7 @@ def init_strategy_tables(conn) -> None:
|
||||
CTP_SIM_POSITIONS_SQL,
|
||||
):
|
||||
conn.execute(sql)
|
||||
conn.commit()
|
||||
try:
|
||||
conn.execute("ALTER TABLE trend_pullback_plans ADD COLUMN period TEXT DEFAULT '15m'")
|
||||
except Exception:
|
||||
|
||||
Reference in New Issue
Block a user