ALTER TABLE "calendar_events" ADD COLUMN IF NOT EXISTS "search_request_id" UUID;

ALTER TABLE "calendar_events" DROP CONSTRAINT IF EXISTS "calendar_events_search_request_id_fkey";
ALTER TABLE "calendar_events" ADD CONSTRAINT "calendar_events_search_request_id_fkey"
  FOREIGN KEY ("search_request_id") REFERENCES "search_requests"("id") ON DELETE SET NULL ON UPDATE CASCADE;

CREATE INDEX IF NOT EXISTS "calendar_events_search_request_id_idx" ON "calendar_events"("search_request_id");
