mirror of
https://github.com/Xe138/AI-Trader.git
synced 2026-04-07 03:07:24 -04:00
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
This commit is contained in:
42
tests/unit/test_old_schema_removed.py
Normal file
42
tests/unit/test_old_schema_removed.py
Normal file
@@ -0,0 +1,42 @@
|
||||
"""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
|
||||
Reference in New Issue
Block a user