new awesome build
This commit is contained in:
35
APP_PROFILER/scripts/add_mtu_mss_columns.py
Normal file
35
APP_PROFILER/scripts/add_mtu_mss_columns.py
Normal file
@@ -0,0 +1,35 @@
|
||||
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()
|
||||
Reference in New Issue
Block a user