domovoy_bot/database/migrate_add_meter_reminders.py

29 lines
1,002 B
Python
Raw Permalink 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.16: добавить колонку meter_reminders_enabled в таблицу users
"""
import sqlite3
import asyncio
DB_PATH = 'database/domovoy.db'
async def migrate():
conn = sqlite3.connect(DB_PATH)
cursor = conn.cursor()
# Проверяем, есть ли уже колонка meter_reminders_enabled
cursor.execute("PRAGMA table_info(users)")
columns = [col[1] for col in cursor.fetchall()]
if 'meter_reminders_enabled' in columns:
print(" Колонка meter_reminders_enabled уже существует")
else:
print(" Добавляем колонку meter_reminders_enabled в таблицу users...")
cursor.execute("ALTER TABLE users ADD COLUMN meter_reminders_enabled BOOLEAN DEFAULT 1")
print("✅ Колонка добавлена")
conn.commit()
conn.close()
print("✅ Миграция v1.16 завершена!")
if __name__ == '__main__':
asyncio.run(migrate())