-- AlterTable: Add externalEventId and externalEventUrl columns to Event table
DO $$ 
BEGIN
    -- Add externalEventId column if it doesn't exist
    IF NOT EXISTS (
        SELECT 1 FROM information_schema.columns 
        WHERE table_name = 'Event' AND column_name = 'externalEventId'
    ) THEN
        ALTER TABLE "Event" ADD COLUMN "externalEventId" TEXT;
    END IF;
    
    -- Add externalEventUrl column if it doesn't exist
    IF NOT EXISTS (
        SELECT 1 FROM information_schema.columns 
        WHERE table_name = 'Event' AND column_name = 'externalEventUrl'
    ) THEN
        ALTER TABLE "Event" ADD COLUMN "externalEventUrl" TEXT;
    END IF;
END $$;

-- CreateIndex: Add index on externalEventId for fast matching during sync
CREATE INDEX IF NOT EXISTS "Event_externalEventId_idx" ON "Event"("externalEventId");
