30 lines
944 B
Python
30 lines
944 B
Python
import sqlite3
|
|
import os
|
|
import sys
|
|
|
|
# Путь к БД
|
|
DB_PATH = "/home/matrixhasyou/legal-swarm-core/services/domovoy_bot/database/domovoy.db"
|
|
|
|
def migrate():
|
|
print(f"[*] Starting migration: adding staircase/floor to users...")
|
|
conn = sqlite3.connect(DB_PATH)
|
|
cursor = conn.cursor()
|
|
|
|
try:
|
|
# Добавляем колонки если их нет
|
|
cursor.execute("ALTER TABLE users ADD COLUMN staircase INTEGER;")
|
|
cursor.execute("ALTER TABLE users ADD COLUMN floor INTEGER;")
|
|
print("[+] Columns added successfully.")
|
|
except sqlite3.OperationalError as e:
|
|
print(f"[!] Warning: {e} (Columns might already exist)")
|
|
|
|
# Включаем WAL режим
|
|
cursor.execute("PRAGMA journal_mode=WAL;")
|
|
print(f"[+] WAL mode enabled: {cursor.fetchone()[0]}")
|
|
|
|
conn.commit()
|
|
conn.close()
|
|
print("[*] Migration finished.")
|
|
|
|
if __name__ == "__main__":
|
|
migrate()
|