DO $$
DECLARE
	_path  character varying(256) := 'patch-2026_03_12-AuthClients_ApplicationKey';
	_build integer := 16174;
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."AuthClients" 
            ALTER COLUMN "ApplicationKey" 
                TYPE varchar(255) USING "ApplicationKey"::varchar(255);

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