Commit each schema migration separately on PostgreSQL.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -373,11 +373,11 @@ def init_db():
|
||||
for sql in migrations:
|
||||
try:
|
||||
c.execute(sql)
|
||||
conn.commit()
|
||||
except Exception as exc:
|
||||
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,
|
||||
@@ -430,6 +430,7 @@ def init_db():
|
||||
):
|
||||
try:
|
||||
c.execute(sql)
|
||||
conn.commit()
|
||||
except Exception as exc:
|
||||
if not is_schema_migration_error(exc):
|
||||
raise
|
||||
|
||||
@@ -157,7 +157,9 @@ def init_strategy_tables(conn) -> None:
|
||||
for sql in ROLL_LEG_EXTRA_COLUMNS:
|
||||
try:
|
||||
conn.execute(sql)
|
||||
conn.commit()
|
||||
except Exception:
|
||||
rollback_if_postgres(conn)
|
||||
pass
|
||||
if not conn.execute("SELECT id FROM ctp_sim_account WHERE id=1").fetchone():
|
||||
conn.execute("INSERT INTO ctp_sim_account (id, balance, available) VALUES (1, 100000, 100000)")
|
||||
|
||||
Reference in New Issue
Block a user