Добавлено (волна 6):
- learning: lesson_detail, topic_test, ai_context, practice_start, analytics*
- teacher: resume_no_session, diagnostic_test, answer_flow, history_save_load,
history_clear, free_message*, translate_to_polish*, explain*
- achievements: 8 track-эндпоинтов + user
- users: is_admin, set_level (+ возврат на A1)
- admin: sentry_errors_forbidden
- assistant: stats_personal, stats_admin_forbidden
- support: send, unread_count
- feed: post_detail
- hints: word_list, remaining
- game: progress, check_word
* — AI-эндпоинты, помечены @pytest.mark.skip
Инвентаризация (scripts + результат):
- scripts/dump_inventory.py — собирает эндпоинты + схему БД
- scripts/dump_schema.py — только схема БД (без pool.close, чтобы не висло)
- endpoints_inventory.md — 105 эндпоинтов
- database_schema.md — 40 таблиц
Итого: 58 сценариев, 53 PASSED, 5 SKIPPED (AI), 0 FAILED.
61 lines
2.1 KiB
Python
61 lines
2.1 KiB
Python
#!/usr/bin/env python3
|
|
"""Дамп схемы базы данных. Запуск: python scripts/dump_schema.py"""
|
|
import asyncio
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
sys.path.insert(0, str(Path(__file__).parent.parent))
|
|
|
|
from database import get_pool
|
|
|
|
|
|
async def dump_schema() -> None:
|
|
pool = await get_pool()
|
|
async with pool.acquire() as conn:
|
|
print("🔍 Запрашиваю список таблиц...")
|
|
tables = await conn.fetch("""
|
|
SELECT table_name
|
|
FROM information_schema.tables
|
|
WHERE table_schema = 'public'
|
|
AND table_type = 'BASE TABLE'
|
|
ORDER BY table_name
|
|
""")
|
|
print(f"📋 Найдено таблиц: {len(tables)}")
|
|
|
|
lines = ["# 🗄 Схема базы данных", ""]
|
|
total = 0
|
|
|
|
for t in tables:
|
|
table_name = t["table_name"]
|
|
print(f" → {table_name}")
|
|
lines.append(f"## {table_name}")
|
|
lines.append("")
|
|
|
|
cols = await conn.fetch("""
|
|
SELECT column_name, data_type, is_nullable, column_default
|
|
FROM information_schema.columns
|
|
WHERE table_name = $1
|
|
ORDER BY ordinal_position
|
|
""", table_name)
|
|
|
|
lines.append("| Колонка | Тип | NULL | Default |")
|
|
lines.append("|---------|-----|------|---------|")
|
|
for c in cols:
|
|
nullable = "YES" if c["is_nullable"] == "YES" else "NO"
|
|
default = (c["column_default"] or "")[:50]
|
|
lines.append(f"| {c['column_name']} | {c['data_type']} | {nullable} | {default} |")
|
|
lines.append("")
|
|
total += 1
|
|
|
|
Path("database_schema.md").write_text("\n".join(lines), encoding="utf-8")
|
|
print(f"✅ database_schema.md — {total} таблиц")
|
|
|
|
|
|
async def main() -> None:
|
|
await dump_schema()
|
|
print("🎉 Готово!")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
# БЕЗ pool.close() — пул закроется сам при выходе процесса.
|
|
asyncio.run(main()) |