domovoy_bot/database/migrate_add_toxicity.py
Admin ba4676b0af v1.0 MVP - Инициализация проекта 🏠
 Регистрация и верификация жильцов
 Рейтинг активности (уровни)
 Детект шпионов (Score 0-100)
 Анти-мат система (3 предупреждения → бан)
 Админ-панель с рассылкой
 Учёт квартир (несколько жильцов)
 Телефоны экстренных служб и мастеров
 Еженедельный экспорт JSON
 Прокси (socks5) для обхода РКН

Бекап: backups/versions/v1.0_mvp_2026-02-26/

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-02-27 10:54:16 +00:00

46 lines
1.7 KiB
Python
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""
Миграция v1.9: добавить поля для рейтинга токсичности
"""
import sqlite3
import asyncio
DB_PATH = 'database/domovoy.db'
async def migrate():
"""Добавить поля для токсичности"""
conn = sqlite3.connect(DB_PATH)
cursor = conn.cursor()
# Проверяем есть ли поля в users
cursor.execute("PRAGMA table_info(users)")
columns = [col[1] for col in cursor.fetchall()]
if 'toxicity_score' not in columns:
print(" Добавляем поле toxicity_score...")
cursor.execute("ALTER TABLE users ADD COLUMN toxicity_score INTEGER DEFAULT 0")
print("✅ Поле toxicity_score добавлено")
else:
print(" Поле toxicity_score уже существует")
if 'toxic_messages_count' not in columns:
print(" Добавляем поле toxic_messages_count...")
cursor.execute("ALTER TABLE users ADD COLUMN toxic_messages_count INTEGER DEFAULT 0")
print("✅ Поле toxic_messages_count добавлено")
else:
print(" Поле toxic_messages_count уже существует")
if 'complaints_count' not in columns:
print(" Добавляем поле complaints_count...")
cursor.execute("ALTER TABLE users ADD COLUMN complaints_count INTEGER DEFAULT 0")
print("✅ Поле complaints_count добавлено")
else:
print(" Поле complaints_count уже существует")
conn.commit()
conn.close()
print("✅ Миграция v1.9 завершена!")
if __name__ == '__main__':
asyncio.run(migrate())