Files
OnEverDrive/backend/migrate_mirroring.py

37 lines
1.4 KiB
Python

import sqlite3
import os
DB_PATH = os.path.join(os.path.dirname(__file__), "onever_drive.db")
def migrate():
print(f"Connecting to {DB_PATH}...")
conn = sqlite3.connect(DB_PATH)
cursor = conn.cursor()
# Add sync_deletions to backup_jobs
try:
cursor.execute("ALTER TABLE backup_jobs ADD COLUMN sync_deletions BOOLEAN DEFAULT 0 NOT NULL")
print("Column 'sync_deletions' added to backup_jobs.")
except sqlite3.OperationalError as e:
print(f"Could not add 'sync_deletions' (maybe it already exists?): {e}")
# Add client_relative_path to backup_sessions
try:
cursor.execute("ALTER TABLE backup_sessions ADD COLUMN client_relative_path VARCHAR(1024) NULL")
print("Column 'client_relative_path' added to backup_sessions.")
except sqlite3.OperationalError as e:
print(f"Could not add 'client_relative_path' to backup_sessions (maybe it already exists?): {e}")
# Add client_relative_path to backup_files
try:
cursor.execute("ALTER TABLE backup_files ADD COLUMN client_relative_path VARCHAR(1024) DEFAULT '' NOT NULL")
print("Column 'client_relative_path' added to backup_files.")
except sqlite3.OperationalError as e:
print(f"Could not add 'client_relative_path' to backup_files (maybe it already exists?): {e}")
conn.commit()
conn.close()
if __name__ == "__main__":
migrate()