44 lines
1.2 KiB
Python
44 lines
1.2 KiB
Python
"""
|
|
Migration script to add thumbnail_path field to projects table.
|
|
"""
|
|
import sqlite3
|
|
from pathlib import Path
|
|
|
|
# Database path
|
|
DB_PATH = Path(__file__).parent / "vfx_project_management.db"
|
|
|
|
|
|
def migrate():
|
|
"""Add thumbnail_path column to projects table."""
|
|
conn = sqlite3.connect(DB_PATH)
|
|
cursor = conn.cursor()
|
|
|
|
try:
|
|
# Check if column already exists
|
|
cursor.execute("PRAGMA table_info(projects)")
|
|
columns = [column[1] for column in cursor.fetchall()]
|
|
|
|
if "thumbnail_path" not in columns:
|
|
print("Adding thumbnail_path column to projects table...")
|
|
cursor.execute("""
|
|
ALTER TABLE projects
|
|
ADD COLUMN thumbnail_path VARCHAR
|
|
""")
|
|
conn.commit()
|
|
print("✓ Successfully added thumbnail_path column")
|
|
else:
|
|
print("✓ thumbnail_path column already exists")
|
|
|
|
except Exception as e:
|
|
print(f"✗ Error during migration: {e}")
|
|
conn.rollback()
|
|
raise
|
|
finally:
|
|
conn.close()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
print("Starting project thumbnail migration...")
|
|
migrate()
|
|
print("Migration completed!")
|