Files
robinhood/backend/migrate_journal_tables.py
Krikorios 48e60d015f feat: Add Phase 4 advanced metrics and components
- Add advanced metrics dashboard with trade analytics
- Add new trading components (EntryTypeAnalysis, MultiDayPositionTracker, NewsEventTracker, etc.)
- Add strategy mode selector and trend confirmation
- Add risk automation panel and slippage correlation analysis
- Add daily trading plan enhancements with modal components
- Add custom hooks (useApi, useLocalStorage, useAdvancedTradeMetrics)
- Add broker service integration and trading API
- Add test setup and vitest configuration
- Include parquet data files for live market data
- Add comprehensive documentation in docs/ folder
2025-11-27 10:23:58 +02:00

50 lines
1.3 KiB
Python

"""
Database migration script to add trading journal tables
Run this to create the new journal-related tables without affecting existing data
"""
import sys
import os
# Add the backend directory to the path
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from app.db.database import engine, Base
from app.models.models import (
TradingPlan,
ManualTrade,
JournalEntry,
DecisionLog,
WeeklyPlan
)
def migrate_journal_tables():
"""Create journal tables if they don't exist"""
print("Starting journal tables migration...")
try:
# Import all models to ensure they're registered with Base
from app.models import models
# Create only the new tables (won't affect existing tables)
print("Creating journal tables...")
Base.metadata.create_all(bind=engine, checkfirst=True)
print("✅ Journal tables migration completed successfully!")
print("\nNew tables created:")
print(" - trading_plans")
print(" - manual_trades")
print(" - journal_entries")
print(" - decision_log")
print(" - weekly_plans")
except Exception as e:
print(f"❌ Migration failed: {e}")
import traceback
traceback.print_exc()
sys.exit(1)
if __name__ == "__main__":
migrate_journal_tables()