"""Add url column to content table for web link playlist items. Web link items are stored as Content rows with content_type='weblink' and the target web page URL in the new 'url' column (NULL for file-based content). Run with: python migrations/add_weblink_url_to_content.py """ import sys sys.path.insert(0, '/app') from app.app import create_app from app.extensions import db from sqlalchemy import text app = create_app() with app.app_context(): print("Adding url column to content table...") try: inspector = db.inspect(db.engine) columns = [col['name'] for col in inspector.get_columns('content')] if 'url' not in columns: with db.engine.connect() as conn: conn.execute(text('ALTER TABLE content ADD COLUMN url VARCHAR(2048)')) conn.commit() print("\u2713 url column added to content table!") else: print("\u2713 url column already exists in content table.") except Exception as e: print(f"Error adding url column: {str(e)}") sys.exit(1)