DO $$
DECLARE 
    _path character varying(256) := 'patch-2025-11-21-MessageSettings';
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
     	DELETE FROM public."MessageSettings" WHERE "Key"='Single.Reindex.Email';

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