DO $$
DECLARE 
    _path character varying(256) := 'patch-2025-11-12-EventDetails';
BEGIN
    IF EXISTS (SELECT "Id" FROM public."Versions" WHERE "Path" = _path) THEN
        RETURN;
    END IF;

    IF EXISTS (SELECT "Id" FROM public."Versions" WHERE "Build" >= 15620) THEN
        RETURN;
    END IF;

    BEGIN
     UPDATE public."EventDetails" SET "Uid" = gen_random_uuid() WHERE "Uid" IS NULL;

        	INSERT INTO public."Versions" ("Path", "Build") VALUES (_path, 0);
    END;
END;
$$;