Files

36 lines
914 B
Python
Raw Permalink Normal View History

2026-01-28 22:37:47 +03:00
import sqlite3
import os
DB_FILE = "ovpn_profiler.db"
def migrate():
if not os.path.exists(DB_FILE):
print(f"Database {DB_FILE} not found!")
return
conn = sqlite3.connect(DB_FILE)
cursor = conn.cursor()
columns = {
"tun_mtu": "INTEGER",
"mssfix": "INTEGER"
}
print("Checking for new columns...")
for col, dtype in columns.items():
try:
print(f"Attempting to add {col}...")
cursor.execute(f"ALTER TABLE system_settings ADD COLUMN {col} {dtype}")
print(f"Success: Column {col} added.")
except sqlite3.OperationalError as e:
if "duplicate column name" in str(e):
print(f"Column {col} already exists.")
else:
print(f"Error adding {col}: {e}")
conn.commit()
conn.close()
if __name__ == "__main__":
migrate()