Update wiki page 'Database' in Russian

2026-04-24 11:05:49 +03:00
parent cb028513d5
commit 14a6069524
+63 -63
@@ -1,122 +1,122 @@
# Database # Database
GM-Relay uses PostgreSQL. Schema changes are managed by DbUp migrations embedded in `GmRelay.Bot`. GM-Relay использует PostgreSQL. Изменения схемы управляются DbUp-миграциями, встроенными в `GmRelay.Bot`.
## Migrations ## Миграции
Current migrations: Текущие миграции:
- `V001__initial_schema.sql`base tables for players, groups, sessions and participants. - `V001__initial_schema.sql`базовые таблицы для игроков, групп, сессий и участников.
- `V002__add_session_batch.sql``sessions.batch_id` for batch scheduling. - `V002__add_session_batch.sql` поле `sessions.batch_id` для пачек сессий.
- `V003__add_thread_id.sql``sessions.thread_id` for Telegram forum topics. - `V003__add_thread_id.sql` поле `sessions.thread_id` для Telegram forum topics.
- `V004__add_reschedule_proposals.sql`proposal/vote tables for rescheduling. - `V004__add_reschedule_proposals.sql`таблицы предложений переноса и голосов.
- `V005__add_batch_message_id.sql``sessions.batch_message_id` for editing the original batch message. - `V005__add_batch_message_id.sql` поле `sessions.batch_message_id` для редактирования исходного сообщения расписания.
## Core tables ## Основные таблицы
### players ### players
Known Telegram users. Известные Telegram-пользователи, которые взаимодействовали с ботом.
Important fields: Важные поля:
- `telegram_id`unique Telegram user ID. - `telegram_id`уникальный Telegram ID пользователя.
- `display_name`current display name captured from Telegram. - `display_name`актуальное отображаемое имя, полученное из Telegram.
- `telegram_username`optional username. - `telegram_username`username пользователя, если он есть.
### game_groups ### game_groups
Telegram groups where games are organized. Telegram-группы, где организуются игры.
Important fields: Важные поля:
- `telegram_chat_id`unique Telegram chat ID. - `telegram_chat_id`уникальный Telegram chat ID.
- `name`current Telegram chat title. - `name`актуальное название Telegram-чата.
- `gm_telegram_id` — Telegram ID of the GM for this group. - `gm_telegram_id` — Telegram ID ГМа для этой группы.
### game_group_members ### game_group_members
Membership table between groups and players. The current feature set mostly works through session participation and `gm_telegram_id`; this table is part of the base schema for group membership. Таблица связи групп и игроков. Текущая функциональность в основном работает через участие в конкретных сессиях и `gm_telegram_id`; таблица остаётся частью базовой схемы для группового membership.
### sessions ### sessions
Individual game sessions. Отдельные игровые сессии.
Important fields: Важные поля:
- `batch_id`groups multiple sessions created by one `/newsession` command. - `batch_id`объединяет несколько сессий, созданных одной командой `/newsession`.
- `group_id` owning Telegram group. - `group_id` — Telegram-группа, которой принадлежит сессия.
- `title`game title. - `title`название игры.
- `join_link`connection link sent before the game. - `join_link`ссылка для подключения, отправляемая перед началом игры.
- `scheduled_at`UTC timestamp. - `scheduled_at`дата и время в UTC.
- `status``Planned`, `ConfirmationSent`, `Confirmed`, or `Cancelled`. - `status``Planned`, `ConfirmationSent`, `Confirmed` или `Cancelled`.
- `confirmation_message_id` — Telegram message ID for RSVP prompt. - `confirmation_message_id` ID Telegram-сообщения с RSVP-подтверждением.
- `link_message_id` — Telegram message ID for pre-game link reminder. - `link_message_id` ID Telegram-сообщения с pre-game ссылкой.
- `thread_id` — Telegram forum topic ID, if created. - `thread_id` ID Telegram forum topic, если тема была создана.
- `batch_message_id`original Telegram message with batch schedule. - `batch_message_id`ID исходного Telegram-сообщения с расписанием пачки.
There is a partial index `ix_sessions_pending` over `scheduled_at` for active statuses. Для активных статусов есть partial index `ix_sessions_pending` по `scheduled_at`.
### session_participants ### session_participants
Per-session player participation and RSVP state. Участники конкретных сессий и их RSVP-состояние.
Important fields: Важные поля:
- `session_id` and `player_id`unique pair. - `session_id` и `player_id`уникальная пара сессии и игрока.
- `is_gm`whether participant is the GM. - `is_gm`признак, что участник является ГМом.
- `rsvp_status``Pending`, `Confirmed`, or `Declined`. - `rsvp_status``Pending`, `Confirmed` или `Declined`.
- `responded_at`RSVP timestamp. - `responded_at`время RSVP-ответа.
## Reschedule tables ## Таблицы переноса сессий
### reschedule_proposals ### reschedule_proposals
Tracks one active reschedule flow per session. Отслеживает один активный сценарий переноса для сессии.
Important fields: Важные поля:
- `session_id`target session. - `session_id`целевая сессия.
- `proposed_at`proposed new UTC time; null while waiting for GM input. - `proposed_at`новое предложенное время в UTC; `NULL`, пока бот ждёт ввод времени от ГМа.
- `proposed_by` GM Telegram ID. - `proposed_by` — Telegram ID ГМа.
- `status``AwaitingTime`, `Voting`, `Approved`, `Rejected`. - `status``AwaitingTime`, `Voting`, `Approved`, `Rejected`.
- `vote_message_id` and `vote_chat_id`Telegram voting message location. - `vote_message_id` и `vote_chat_id`где находится Telegram-сообщение голосования.
A partial unique index allows only one active proposal per session while status is `AwaitingTime` or `Voting`. Partial unique index разрешает только одно активное предложение переноса на сессию, пока статус `AwaitingTime` или `Voting`.
### reschedule_votes ### reschedule_votes
Stores participant votes for a proposal. Хранит голоса участников по предложению переноса.
Important fields: Важные поля:
- `proposal_id`. - `proposal_id` — предложение переноса.
- `player_id`. - `player_id` — игрок, который голосует.
- `vote``yes` or `no`. - `vote``yes` или `no`.
- `voted_at`. - `voted_at` — время голосования.
Each participant has one vote per proposal; repeated voting updates the stored vote. У каждого участника один голос на предложение. Повторное голосование обновляет сохранённый голос.
## Status model ## Модель статусов
Session statuses: Статусы сессии:
```text ```text
Planned -> ConfirmationSent -> Confirmed Planned -> ConfirmationSent -> Confirmed
Planned -> Cancelled Planned -> Cancelled
ConfirmationSent -> Cancelled ConfirmationSent -> Cancelled
Confirmed -> ConfirmationSent, if a confirmed participant later declines Confirmed -> ConfirmationSent, если подтвердивший участник позже отказался
``` ```
Reschedule statuses: Статусы переноса:
```text ```text
AwaitingTime -> Voting -> Approved AwaitingTime -> Voting -> Approved
AwaitingTime -> Voting -> Rejected AwaitingTime -> Voting -> Rejected
AwaitingTime -> Approved, if no participants exist AwaitingTime -> Approved, если участников нет
``` ```
RSVP statuses: RSVP-статусы:
```text ```text
Pending -> Confirmed Pending -> Confirmed
@@ -125,8 +125,8 @@ Confirmed -> Declined
Declined -> Confirmed Declined -> Confirmed
``` ```
## Time handling ## Работа со временем
User-facing input and output are Moscow time (`UTC+3`). `MoscowTime.TryParseMoscow` converts accepted local formats into UTC before saving to `scheduled_at`. Пользовательский ввод и вывод работают в московском времени (`UTC+3`). `MoscowTime.TryParseMoscow` преобразует поддерживаемые локальные форматы в UTC перед сохранением в `scheduled_at`.
Web edit form shows Moscow time, then converts it back to UTC before updating the database. Web-форма редактирования показывает московское время, а перед обновлением БД преобразует его обратно в UTC.