DO $$
DECLARE
	_path  character varying(256) := 'patch-2026_03_18-TaskDeviceUid.sql';
	_build integer := 16316;
BEGIN
	IF EXISTS (SELECT 1 FROM public."Versions" WHERE "Path" = _path) THEN
		RETURN;
	END IF;

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

	BEGIN
        ALTER TABLE public."Tasks" ADD column IF NOT exists "DeviceUid" character varying(64);

	EXCEPTION
		WHEN OTHERS THEN
			RAISE NOTICE '[ERR] %: %', _path, SQLERRM;
	END;
END;
$$;
