mirror of
https://github.com/Xe138/AI-Trader.git
synced 2026-04-09 04:07:24 -04:00
Compare commits
1 Commits
v0.3.0-alp
...
v0.3.0-alp
| Author | SHA1 | Date | |
|---|---|---|---|
| 2575e0c12a |
@@ -203,6 +203,9 @@ def initialize_database(db_path: str = "data/jobs.db") -> None:
|
|||||||
)
|
)
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
# Run schema migrations for existing databases
|
||||||
|
_migrate_schema(cursor)
|
||||||
|
|
||||||
# Create indexes for performance
|
# Create indexes for performance
|
||||||
_create_indexes(cursor)
|
_create_indexes(cursor)
|
||||||
|
|
||||||
@@ -210,6 +213,21 @@ def initialize_database(db_path: str = "data/jobs.db") -> None:
|
|||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
|
|
||||||
|
def _migrate_schema(cursor: sqlite3.Cursor) -> None:
|
||||||
|
"""Migrate existing database schema to latest version."""
|
||||||
|
# Check if positions table exists and has simulation_run_id column
|
||||||
|
cursor.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='positions'")
|
||||||
|
if cursor.fetchone():
|
||||||
|
cursor.execute("PRAGMA table_info(positions)")
|
||||||
|
columns = [row[1] for row in cursor.fetchall()]
|
||||||
|
|
||||||
|
if 'simulation_run_id' not in columns:
|
||||||
|
# Add simulation_run_id column to existing positions table
|
||||||
|
cursor.execute("""
|
||||||
|
ALTER TABLE positions ADD COLUMN simulation_run_id TEXT
|
||||||
|
""")
|
||||||
|
|
||||||
|
|
||||||
def _create_indexes(cursor: sqlite3.Cursor) -> None:
|
def _create_indexes(cursor: sqlite3.Cursor) -> None:
|
||||||
"""Create database indexes for query performance."""
|
"""Create database indexes for query performance."""
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user