collabrix/backend/scripts/add_theme_to_user.py
DGSoft 93b98cfb5c Initial commit: Team Chat System with Code Snippet Library
- Complete chat application similar to Microsoft Teams
- Code snippet library with syntax highlighting
- Real-time messaging with WebSockets
- File upload with Office integration
- Department-based permissions
- Dark/Light theme support
- Production deployment with SSL/Reverse Proxy
- Docker containerization
- PostgreSQL database with SQLModel ORM
2025-12-09 22:25:03 +01:00

45 lines
1.1 KiB
Python

#!/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)