[Eva] teacher_materials: авто-миграция example_* колонок
This commit is contained in:
+16
@@ -1229,6 +1229,22 @@ async def init_db():
|
|||||||
ON teacher_materials USING GIN (tags)
|
ON teacher_materials USING GIN (tags)
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
# 🔧 НОВОЕ (04.11.2026): example_* — примеры к материалу.
|
||||||
|
# Правила грамматики состоят из трёх частей: заголовок (title),
|
||||||
|
# описание (content) и примеры (example). Для существующих БД
|
||||||
|
# добавляем колонки через ALTER TABLE (CREATE TABLE IF NOT EXISTS
|
||||||
|
# их не добавит).
|
||||||
|
for ex_col in ("example_pl", "example_ru", "example_uk", "example_en"):
|
||||||
|
col_exists = await conn.fetchval("""
|
||||||
|
SELECT 1 FROM information_schema.columns
|
||||||
|
WHERE table_name = 'teacher_materials' AND column_name = $1
|
||||||
|
""", ex_col)
|
||||||
|
if not col_exists:
|
||||||
|
await conn.execute(
|
||||||
|
f"ALTER TABLE teacher_materials ADD COLUMN {ex_col} TEXT"
|
||||||
|
)
|
||||||
|
logger.info(f"Added {ex_col} column to teacher_materials")
|
||||||
|
|
||||||
logger.info("Table teacher_materials initialized")
|
logger.info("Table teacher_materials initialized")
|
||||||
|
|
||||||
# ============ lectures — лекции (архивы) ============
|
# ============ lectures — лекции (архивы) ============
|
||||||
|
|||||||
Reference in New Issue
Block a user