forked from mtusi2026/mtusi2026lab2
Переносит минимум lab1 на PostgreSQL, добавляет Argon2id, Basic-вход, opaque Bearer-сессии в Valkey с TTL и AOF, строгую валидацию JSON, keyset-пагинацию по индексу, миграции, compose-стенд и собственные проверки уровня 3/4. Трек 5 — план запроса и восстановление.
16 lines
580 B
SQL
16 lines
580 B
SQL
-- Indexes justified by the two keyset queries of the contract.
|
|
--
|
|
-- Message history:
|
|
-- WHERE chat_id = $1 AND (created_at, id) > ($2, $3)
|
|
-- ORDER BY created_at, id LIMIT $4
|
|
-- The three-column index lets PostgreSQL start at the cursor position inside
|
|
-- one chat instead of scanning the whole history for every page.
|
|
CREATE INDEX messages_chat_created_id_idx
|
|
ON messages (chat_id, created_at, id);
|
|
|
|
-- Chat list:
|
|
-- ORDER BY created_at, id LIMIT $1
|
|
-- after joining chat_members for the current user.
|
|
CREATE INDEX chats_created_id_idx
|
|
ON chats (created_at, id);
|