Skip to main content
The schema isn’t kept as migrations in a repository today. This page is reconstructed from the columns the API code reads and writes (October 2026) plus the March 2026 leaderboard migration. Treat the Supabase dashboard as the final word, and update this page when you change a table.

Entity relationships

Tables

One row per player, keyed by the Supabase Auth user ID. Written by UserSyncService (upsert, keeps role) and the admin user routes.
The model catalog. ModelSelector caches active rows; ComparisonLogger inserts a row when it meets an unknown model_name.
One row per battle, written by ComparisonLogger after both answers are in.
threads: thread_id (PK), user_id, title, mode (battle, arena, direct), visibility (private, unlisted, public; default private), message_count, created_at, updated_at.thread_messages: message_id (PK), thread_id, comparison_id (battles only), prompt_text, model1_name, model2_name (null for direct chat), model1_response, model2_response, model1_time_ms, model2_time_ms, position (1, 2, 3, …), created_at.
ELO state per model, from the March 2026 leaderboard migration.
providers: provider_name (PK, lowercase), display_name, is_enabled, priority, created_at, updated_at.provider_api_keys: key_id (PK), provider_name, api_key, display_mask (last four characters), is_active, failure_count, total_calls, last_used_at, last_error_type, last_error_category, cooldown_until, created_by, created_at, updated_at. Used by the key pool when AI Gateway BYOK is off; see Provider integration.
Feature flags. key (PK) plus either a boolean is_enabled or a text value (true, 1, yes, enabled count as on). Missing flags read as off. Known flag: public_sharing.
telegram_chat_id (key), jwt_token and refresh_token (encrypted with APP_SECRET), jwt_expires_at, updated_at. Written by the Telegram bot.

Views and functions

Storage and functions outside Postgres

  • Storage bucket avatars (profile pictures, arena).
  • Edge Functions send-admin-email (admin panel) and email-wel-safe (arena welcome email).
Last modified on October 18, 2026