INSERT INTO app_settings(key, value_json, value_type, title, description, category)
VALUES
  ('video_max_height', '720'::jsonb, 'int', 'Video max height', 'Maximum VK video height selected by yt-dlp before uploading to Telegram.', 'Uploader')
ON CONFLICT (key) DO NOTHING;

UPDATE app_settings
SET value_json='600'::jsonb,
    updated_at=NOW()
WHERE key='uploader_yt_dlp_timeout_sec'
  AND CASE
        WHEN jsonb_typeof(value_json) = 'number' THEN (value_json #>> '{}')::int
        WHEN jsonb_typeof(value_json) = 'string' AND (value_json #>> '{}') ~ '^\d+$' THEN (value_json #>> '{}')::int
        ELSE 0
      END < 600;
