29 lines
720 B
Python
29 lines
720 B
Python
|
|
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()
|
||
|
|
|
||
|
|
try:
|
||
|
|
print("Attempting to add public_ip column...")
|
||
|
|
cursor.execute("ALTER TABLE system_settings ADD COLUMN public_ip TEXT")
|
||
|
|
conn.commit()
|
||
|
|
print("Success: Column public_ip added.")
|
||
|
|
except sqlite3.OperationalError as e:
|
||
|
|
if "duplicate column name" in str(e):
|
||
|
|
print("Column public_ip already exists.")
|
||
|
|
else:
|
||
|
|
print(f"Error: {e}")
|
||
|
|
finally:
|
||
|
|
conn.close()
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
migrate()
|