#!/usr/bin/env python3 """ Migration script to add theme column to user table """ import sys import os # Add parent directory to path to import app modules sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from sqlalchemy import text from app.database import engine def migrate(): """Add theme column to user table""" with engine.connect() as conn: # Check if column already exists result = conn.execute(text(""" SELECT column_name FROM information_schema.columns WHERE table_name='user' AND column_name='theme' """)) if result.fetchone(): print("✅ Column 'theme' already exists in user table") return # Add theme column conn.execute(text(""" ALTER TABLE "user" ADD COLUMN theme VARCHAR(10) DEFAULT 'light' """)) conn.commit() print("✅ Successfully added 'theme' column to user table") if __name__ == "__main__": try: migrate() except Exception as e: print(f"❌ Migration failed: {e}") sys.exit(1)