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,
|
trigger_price REAL, stop_loss REAL, take_profit REAL,
|
||||||
result TEXT,
|
result TEXT,
|
||||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP)''')
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP)''')
|
||||||
|
conn.commit()
|
||||||
migrations = [
|
migrations = [
|
||||||
"ALTER TABLE key_monitors ADD COLUMN symbol_name TEXT",
|
"ALTER TABLE key_monitors ADD COLUMN symbol_name TEXT",
|
||||||
"ALTER TABLE key_monitors ADD COLUMN upper_triggered INTEGER DEFAULT 0",
|
"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):
|
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,
|
||||||
@@ -422,6 +424,7 @@ def init_db():
|
|||||||
(key TEXT PRIMARY KEY,
|
(key TEXT PRIMARY KEY,
|
||||||
data_json TEXT NOT NULL,
|
data_json TEXT NOT NULL,
|
||||||
updated_at TEXT NOT NULL)''')
|
updated_at TEXT NOT NULL)''')
|
||||||
|
conn.commit()
|
||||||
for sql in (
|
for sql in (
|
||||||
"ALTER TABLE fee_rates ADD COLUMN source TEXT DEFAULT 'local'",
|
"ALTER TABLE fee_rates ADD COLUMN source TEXT DEFAULT 'local'",
|
||||||
):
|
):
|
||||||
|
|||||||
@@ -149,6 +149,7 @@ def init_strategy_tables(conn) -> None:
|
|||||||
CTP_SIM_POSITIONS_SQL,
|
CTP_SIM_POSITIONS_SQL,
|
||||||
):
|
):
|
||||||
conn.execute(sql)
|
conn.execute(sql)
|
||||||
|
conn.commit()
|
||||||
try:
|
try:
|
||||||
conn.execute("ALTER TABLE trend_pullback_plans ADD COLUMN period TEXT DEFAULT '15m'")
|
conn.execute("ALTER TABLE trend_pullback_plans ADD COLUMN period TEXT DEFAULT '15m'")
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|||||||
Reference in New Issue
Block a user