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:
|
for sql in migrations:
|
||||||
try:
|
try:
|
||||||
c.execute(sql)
|
c.execute(sql)
|
||||||
|
conn.commit()
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
if not is_schema_migration_error(exc):
|
if not is_schema_migration_error(exc):
|
||||||
raise
|
raise
|
||||||
rollback_if_postgres(conn)
|
rollback_if_postgres(conn)
|
||||||
conn.commit()
|
|
||||||
c.execute('''CREATE TABLE IF NOT EXISTS review_records
|
c.execute('''CREATE TABLE IF NOT EXISTS review_records
|
||||||
(id INTEGER PRIMARY KEY AUTOINCREMENT,
|
(id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
open_time TEXT, close_time TEXT,
|
open_time TEXT, close_time TEXT,
|
||||||
@@ -430,6 +430,7 @@ def init_db():
|
|||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
c.execute(sql)
|
c.execute(sql)
|
||||||
|
conn.commit()
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
if not is_schema_migration_error(exc):
|
if not is_schema_migration_error(exc):
|
||||||
raise
|
raise
|
||||||
|
|||||||
@@ -157,7 +157,9 @@ def init_strategy_tables(conn) -> None:
|
|||||||
for sql in ROLL_LEG_EXTRA_COLUMNS:
|
for sql in ROLL_LEG_EXTRA_COLUMNS:
|
||||||
try:
|
try:
|
||||||
conn.execute(sql)
|
conn.execute(sql)
|
||||||
|
conn.commit()
|
||||||
except Exception:
|
except Exception:
|
||||||
|
rollback_if_postgres(conn)
|
||||||
pass
|
pass
|
||||||
if not conn.execute("SELECT id FROM ctp_sim_account WHERE id=1").fetchone():
|
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)")
|
conn.execute("INSERT INTO ctp_sim_account (id, balance, available) VALUES (1, 100000, 100000)")
|
||||||
|
|||||||
Reference in New Issue
Block a user