Files
AI-Trader/tests/unit/test_old_schema_removed.py
Bill 45cd1e12b6 feat: drop old schema tables (trading_sessions, positions, reasoning_logs)
- Created migration script to drop old tables
- Removed old table creation from database.py
- Added tests to verify old tables are removed and new tables exist
- Migration script can be run standalone with: PYTHONPATH=. python api/migrations/002_drop_old_schema.py
2025-11-04 10:26:00 -05:00

43 lines
1.0 KiB
Python

"""Verify old schema tables are removed."""
import pytest
from api.database import Database
def test_old_tables_do_not_exist():
"""Verify trading_sessions, old positions, reasoning_logs don't exist."""
db = Database(":memory:")
# Query sqlite_master for old tables
cursor = db.connection.execute("""
SELECT name FROM sqlite_master
WHERE type='table' AND name IN (
'trading_sessions', 'reasoning_logs'
)
""")
tables = cursor.fetchall()
assert len(tables) == 0, f"Old tables should not exist, found: {tables}"
def test_new_tables_exist():
"""Verify new schema tables exist."""
db = Database(":memory:")
cursor = db.connection.execute("""
SELECT name FROM sqlite_master
WHERE type='table' AND name IN (
'trading_days', 'holdings', 'actions'
)
ORDER BY name
""")
tables = [row[0] for row in cursor.fetchall()]
assert 'trading_days' in tables
assert 'holdings' in tables
assert 'actions' in tables