-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmigrate.py
More file actions
23 lines (19 loc) · 956 Bytes
/
migrate.py
File metadata and controls
23 lines (19 loc) · 956 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import asyncio
import aiosqlite
DB_PATH = "bot.db"
async def migrate():
print(f"🔄 Начинаю миграцию {DB_PATH}...")
async with aiosqlite.connect(DB_PATH) as db:
try:
# Добавляем колонку is_active (Boolean), по умолчанию True (1)
# Чтобы все старые задачи остались активными
await db.execute("ALTER TABLE tasks ADD COLUMN is_active BOOLEAN DEFAULT 1")
await db.commit()
print("✅ Успешно: Колонка 'is_active' добавлена.")
except Exception as e:
if "duplicate column name" in str(e):
print("ℹ️ Колонка 'is_active' уже существует. Миграция не требуется.")
else:
print(f"❌ Ошибка миграции: {e}")
if __name__ == "__main__":
asyncio.run(migrate())