diff --git a/app.py b/app.py index 0260084..5d09d20 100644 --- a/app.py +++ b/app.py @@ -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 diff --git a/strategy/strategy_db.py b/strategy/strategy_db.py index e29d822..5432f5d 100644 --- a/strategy/strategy_db.py +++ b/strategy/strategy_db.py @@ -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)")