mirror of
https://github.com/Xe138/AI-Trader.git
synced 2026-04-02 01:27:24 -04:00
Fixes startup error 'no such column: session_id' that occurs when _create_indexes() tries to create indexes on columns that don't exist yet. The issue occurred when initializing a database from scratch: 1. _migrate_schema() adds session_id column to positions table 2. _create_indexes() tries to create index on session_id 3. But on fresh databases, positions table was created without session_id 4. Migration runs after table creation, before index creation 5. Index creation fails because column doesn't exist yet Solution: Check if columns exist before creating indexes on them. This ensures the database can be initialized both: - Fresh (CREATE TABLE without session_id, then ALTER TABLE, then CREATE INDEX) - Migrated (ALTER TABLE adds column, then CREATE INDEX) Tested: All 21 database tests passing