"""
Migration to add youtube_link column to show, song, and performance tables.
"""
import sys
import os
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

from sqlmodel import Session, create_engine, text
from database import DATABASE_URL

def add_youtube_link_columns():
    engine = create_engine(DATABASE_URL)
    
    tables = ['show', 'song', 'performance']
    
    with Session(engine) as session:
        for table in tables:
            try:
                session.exec(text(f"""
                    ALTER TABLE "{table}" ADD COLUMN IF NOT EXISTS youtube_link VARCHAR
                """))
                session.commit()
                print(f"✅ Added youtube_link to {table}")
            except Exception as e:
                print(f"⚠️ {table}: {e}")

if __name__ == "__main__":
    add_youtube_link_columns()
