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
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.
- `V002__add_session_batch.sql``sessions.batch_id` for batch scheduling.
- `V003__add_thread_id.sql``sessions.thread_id` for Telegram forum topics.
- `V004__add_reschedule_proposals.sql`proposal/vote tables for rescheduling.
- `V005__add_batch_message_id.sql``sessions.batch_message_id` for editing the original batch message.
- `V001__initial_schema.sql`базовые таблицы для игроков, групп, сессий и участников.
- `V002__add_session_batch.sql` поле `sessions.batch_id` для пачек сессий.
- `V003__add_thread_id.sql` поле `sessions.thread_id` для Telegram forum topics.
- `V004__add_reschedule_proposals.sql`таблицы предложений переноса и голосов.
- `V005__add_batch_message_id.sql` поле `sessions.batch_message_id` для редактирования исходного сообщения расписания.
## Core tables
## Основные таблицы
### players
Known Telegram users.
Известные Telegram-пользователи, которые взаимодействовали с ботом.
Important fields:
Важные поля:
- `telegram_id`unique Telegram user ID.
- `display_name`current display name captured from Telegram.
- `telegram_username`optional username.
- `telegram_id`уникальный Telegram ID пользователя.
- `display_name`актуальное отображаемое имя, полученное из Telegram.
- `telegram_username`username пользователя, если он есть.
### game_groups
Telegram groups where games are organized.
Telegram-группы, где организуются игры.
Important fields:
Важные поля:
- `telegram_chat_id`unique Telegram chat ID.
- `name`current Telegram chat title.
- `gm_telegram_id` — Telegram ID of the GM for this group.
- `telegram_chat_id`уникальный Telegram chat ID.
- `name`актуальное название Telegram-чата.
- `gm_telegram_id` — Telegram ID ГМа для этой группы.
### 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
Individual game sessions.
Отдельные игровые сессии.
Important fields:
Важные поля:
- `batch_id`groups multiple sessions created by one `/newsession` command.
- `group_id` owning Telegram group.
- `title`game title.
- `join_link`connection link sent before the game.
- `scheduled_at`UTC timestamp.
- `status``Planned`, `ConfirmationSent`, `Confirmed`, or `Cancelled`.
- `confirmation_message_id` — Telegram message ID for RSVP prompt.
- `link_message_id` — Telegram message ID for pre-game link reminder.
- `thread_id` — Telegram forum topic ID, if created.
- `batch_message_id`original Telegram message with batch schedule.
- `batch_id`объединяет несколько сессий, созданных одной командой `/newsession`.
- `group_id` — Telegram-группа, которой принадлежит сессия.
- `title`название игры.
- `join_link`ссылка для подключения, отправляемая перед началом игры.
- `scheduled_at`дата и время в UTC.
- `status``Planned`, `ConfirmationSent`, `Confirmed` или `Cancelled`.
- `confirmation_message_id` ID Telegram-сообщения с RSVP-подтверждением.
- `link_message_id` ID Telegram-сообщения с pre-game ссылкой.
- `thread_id` ID Telegram forum topic, если тема была создана.
- `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
Per-session player participation and RSVP state.
Участники конкретных сессий и их RSVP-состояние.
Important fields:
Важные поля:
- `session_id` and `player_id`unique pair.
- `is_gm`whether participant is the GM.
- `rsvp_status``Pending`, `Confirmed`, or `Declined`.
- `responded_at`RSVP timestamp.
- `session_id` и `player_id`уникальная пара сессии и игрока.
- `is_gm`признак, что участник является ГМом.
- `rsvp_status``Pending`, `Confirmed` или `Declined`.
- `responded_at`время RSVP-ответа.
## Reschedule tables
## Таблицы переноса сессий
### reschedule_proposals
Tracks one active reschedule flow per session.
Отслеживает один активный сценарий переноса для сессии.
Important fields:
Важные поля:
- `session_id`target session.
- `proposed_at`proposed new UTC time; null while waiting for GM input.
- `proposed_by` GM Telegram ID.
- `session_id`целевая сессия.
- `proposed_at`новое предложенное время в UTC; `NULL`, пока бот ждёт ввод времени от ГМа.
- `proposed_by` — Telegram ID ГМа.
- `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
Stores participant votes for a proposal.
Хранит голоса участников по предложению переноса.
Important fields:
Важные поля:
- `proposal_id`.
- `player_id`.
- `vote``yes` or `no`.
- `voted_at`.
- `proposal_id` — предложение переноса.
- `player_id` — игрок, который голосует.
- `vote``yes` или `no`.
- `voted_at` — время голосования.
Each participant has one vote per proposal; repeated voting updates the stored vote.
У каждого участника один голос на предложение. Повторное голосование обновляет сохранённый голос.
## Status model
## Модель статусов
Session statuses:
Статусы сессии:
```text
Planned -> ConfirmationSent -> Confirmed
Planned -> Cancelled
ConfirmationSent -> Cancelled
Confirmed -> ConfirmationSent, if a confirmed participant later declines
Confirmed -> ConfirmationSent, если подтвердивший участник позже отказался
```
Reschedule statuses:
Статусы переноса:
```text
AwaitingTime -> Voting -> Approved
AwaitingTime -> Voting -> Rejected
AwaitingTime -> Approved, if no participants exist
AwaitingTime -> Approved, если участников нет
```
RSVP statuses:
RSVP-статусы:
```text
Pending -> Confirmed
@@ -125,8 +125,8 @@ Confirmed -> Declined
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.