Кастомизация профиля (о себе, аватар) и просмотр профилей других игроков + общая статистика

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-17 17:27:24 +03:00
co-authored by Claude Opus 4.8
parent b302ec769a
commit 96daddae05
22 changed files with 1106 additions and 23 deletions
@@ -0,0 +1,47 @@
"""Кастомизация профиля: о себе (bio) и аватар (avatar_path).
Идемпотентна: на свежей БД (0001 создаёт схему из актуальных моделей через create_all)
столбцы уже есть → no-op; на существующей БД — добавляет столбцы. render_as_batch включён
в env.py (нужен для ALTER в SQLite).
Revision ID: 0004_user_profile
Revises: 0003_match_lifecycle
Create Date: 2026-06-17
"""
from typing import Sequence, Union
import sqlalchemy as sa
from sqlalchemy import inspect
from alembic import op
revision: str = "0004_user_profile"
down_revision: Union[str, None] = "0003_match_lifecycle"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
bind = op.get_bind()
insp = inspect(bind)
cols = {c["name"] for c in insp.get_columns("users")}
add = []
if "bio" not in cols:
add.append(sa.Column("bio", sa.Text(), nullable=True))
if "avatar_path" not in cols:
add.append(sa.Column("avatar_path", sa.String(255), nullable=True))
if add:
with op.batch_alter_table("users") as b:
for col in add:
b.add_column(col)
def downgrade() -> None:
with op.batch_alter_table("users") as b:
for name in ("avatar_path", "bio"):
try:
b.drop_column(name)
except Exception: # noqa: BLE001
pass