DO $$
DECLARE
	_path  character varying(256) := 'patch-2026_02_24-MessageSettings_ExportTaskHeaders.sql';
	_build integer := 16615;
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

		INSERT INTO public."MessageSettings" ("Key",  "Value", "Lang") VALUES
	 ('Export.Task.Headers','[
  {
    "Name": "Id",
    "ViewName": "ID"
  },
  {
    "Name": "Key",
    "ViewName": "Key"
  },
  {
    "Name": "Url",
    "ViewName": "URL"
  },
  {
    "Name": "Title",
    "ViewName": "Title"
  },
  {
    "Name": "Description",
    "ViewName": "Description"
  },
  {
    "Name": "Status",
    "ViewName": "Status"
  },
  {
    "Name": "Performer",
    "ViewName": "Performer"
  },
  {
    "Name": "Author",
    "ViewName": "Author"
  }
]','en') ON CONFLICT ("Key","Lang") DO UPDATE SET "Value"= EXCLUDED."Value";

INSERT INTO public."MessageSettings" ("Key",  "Value", "Lang") VALUES
	 ('Export.Task.Headers','[
  {
    "Name": "Id",
    "ViewName": "Идентификатор"
  },
  {
    "Name": "Key",
    "ViewName": "Ключ"
  },
  {
    "Name": "Url",
    "ViewName": "Ссылка"
  },
  {
    "Name": "Title",
    "ViewName": "Заголовок"
  },
  {
    "Name": "Description",
    "ViewName": "Описание"
  },
  {
    "Name": "Status",
    "ViewName": "Статус"
  },
  {
    "Name": "Performer",
    "ViewName": "Исполнитель"
  },
  {
    "Name": "Author",
    "ViewName": "Автор"
  }
]','ru') ON CONFLICT ("Key","Lang") DO UPDATE SET "Value"= EXCLUDED."Value";


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

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