#!/usr/bin/env python3 """ Fix project enum values in the database to match the model definitions. """ import sqlite3 from pathlib import Path def fix_project_enums(): """Fix project enum values to match model definitions.""" print("Fixing Project Enum Values") print("=" * 30) db_path = "vfx_project_management.db" try: conn = sqlite3.connect(db_path) cursor = conn.cursor() # Fix project_type values print("1. Fixing project_type values...") cursor.execute("UPDATE projects SET project_type = 'cinema' WHERE project_type = 'CINEMA'") cursor.execute("UPDATE projects SET project_type = 'tv' WHERE project_type = 'TV'") cursor.execute("UPDATE projects SET project_type = 'game' WHERE project_type = 'GAME'") # Fix status values print("2. Fixing status values...") cursor.execute("UPDATE projects SET status = 'planning' WHERE status = 'PLANNING'") cursor.execute("UPDATE projects SET status = 'in_progress' WHERE status = 'IN_PROGRESS'") cursor.execute("UPDATE projects SET status = 'on_hold' WHERE status = 'ON_HOLD'") cursor.execute("UPDATE projects SET status = 'completed' WHERE status = 'COMPLETED'") cursor.execute("UPDATE projects SET status = 'cancelled' WHERE status = 'CANCELLED'") # Commit changes conn.commit() # Verify the changes print("\n3. Verifying changes...") cursor.execute("SELECT id, name, project_type, status FROM projects") projects = cursor.fetchall() for project in projects: print(f" ID {project[0]}: {project[1]} - Type: {project[2]}, Status: {project[3]}") print("\nāœ… Project enum values fixed successfully!") except Exception as e: print(f"āŒ Error: {e}") if conn: conn.rollback() finally: if conn: conn.close() if __name__ == "__main__": fix_project_enums()