Files
coa-server-manager/services/coa-registry/migrations/0003_browse_indexes.sql
T
ДмитрийandClaude Sonnet 5.5 95ab5dd9ef Phase 11: public realm list and detail, Player Mode server browser
Registry: GET /registry/v2/realms (keyset cursors, bounded filters and sorts, indexes per sort,
ETag and a short server-side cache, per-address limit) and /realms/{id}; migrations 3 and 4.
Manager: Servers page (table, filters, sortable columns, detail drawer, module tooltips from the
local catalog, players and bots apart, ping unknown), compatibility of the chosen character with
an advertised realm through the Phase 7/8 rules.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-07 21:56:09 +05:00

8 lines
1004 B
SQL

-- Registry schema, migration 3 (the public list). Forward-only. One partial index per sort, over exactly the rows a public list can show
-- (published, protocol 2) and exactly the expressions the list sorts by, so that a page is an index range scan with a LIMIT even with many thousands of realms.
CREATE INDEX realms_browse_name ON realms ((lower(display_name)), realm_id) WHERE published AND advert_version = 2;
CREATE INDEX realms_browse_players ON realms ((COALESCE(players, 0)::bigint), realm_id) WHERE published AND advert_version = 2;
CREATE INDEX realms_browse_cap ON realms ((COALESCE(level_cap, 0)::bigint), realm_id) WHERE published AND advert_version = 2;
CREATE INDEX realms_browse_created ON realms (created_at, realm_id) WHERE published AND advert_version = 2;
CREATE INDEX realms_browse_modules ON realms USING gin (modules jsonb_path_ops) WHERE published AND advert_version = 2;