forked from Support/sp-hydra-veil-gui
Migrations occur now automatically instead of forcing a database delete
This commit is contained in:
parent
baf7f7cec1
commit
95e0f676df
1 changed files with 37 additions and 17 deletions
|
|
@ -13,6 +13,11 @@ import sys
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
# DISPLAY CHOICES AND RECOVERY UI
|
# DISPLAY CHOICES AND RECOVERY UI
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
|
def failed_migration(db_version_you_have):
|
||||||
|
close_session() # shut down db connection
|
||||||
|
custom_error = "There were issues with migrating your database. We transitioned to a new Database format for new features! Please delete the old version and fetch the new public data (what locations, browsers, ect) This will NOT affect your profiles or browser sessions."
|
||||||
|
recovery_dialog(custom_error, db_version_you_have)
|
||||||
|
|
||||||
def recovery_dialog(custom_error, db_version_you_have):
|
def recovery_dialog(custom_error, db_version_you_have):
|
||||||
"""This ends the app by forcing them to delete the database, move it, or just quit."""
|
"""This ends the app by forcing them to delete the database, move it, or just quit."""
|
||||||
|
|
||||||
|
|
@ -66,19 +71,26 @@ except:
|
||||||
logger.error("Critical Error with database initialization!")
|
logger.error("Critical Error with database initialization!")
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
# are they upgrading from a legacy version?
|
|
||||||
# that would mean the table existed, but not the version table,
|
# ============================================================================
|
||||||
|
# LEGACY DATABASE CHECKS
|
||||||
|
# ============================================================================
|
||||||
|
migration_happened = False
|
||||||
|
|
||||||
|
# are they upgrading from a legacy version? that would mean the table existed, but not the version table,
|
||||||
if not version_table_exists and main_db_exists:
|
if not version_table_exists and main_db_exists:
|
||||||
logger.info(f"[DB MANAGEMENT] We are dealing with a legacy database, we need to transition the user.")
|
logger.info(f"[DB MANAGEMENT] We are dealing with a legacy database, we need to transition the user.")
|
||||||
|
|
||||||
# shut down db connection
|
migration = migrate_sql()
|
||||||
close_session()
|
|
||||||
|
|
||||||
# THEN DISPLAY CHOICES AND RECOVERY UI
|
logger.info(f"[DB MANAGEMENT] Migration result is {migration.valid}.")
|
||||||
custom_error = "Upgrade Time! We transitioned to a new Database format for new features! Please delete the old version and fetch the new public data (what locations, browsers, ect) This will NOT affect your profiles or browser sessions."
|
if migration.valid:
|
||||||
db_version_you_have = "Old System"
|
migration_happened = True
|
||||||
recovery_dialog(custom_error, db_version_you_have)
|
force_sync = True
|
||||||
sys.exit()
|
else:
|
||||||
|
# THEN DISPLAY CHOICES AND RECOVERY UI
|
||||||
|
db_version_you_have = "Old System"
|
||||||
|
failed_migration(db_version_you_have)
|
||||||
|
|
||||||
# If they're still here, then if it's NOT a legacy version,
|
# If they're still here, then if it's NOT a legacy version,
|
||||||
|
|
||||||
|
|
@ -112,15 +124,17 @@ if is_compatable:
|
||||||
|
|
||||||
except:
|
except:
|
||||||
logger.info(f"[DB MANAGEMENT] create ALL tables failed. Running migrations...")
|
logger.info(f"[DB MANAGEMENT] create ALL tables failed. Running migrations...")
|
||||||
made_tables = migrate_sql()
|
migration = migrate_sql()
|
||||||
logger.info(f"[DB MANAGEMENT] Results of migration is {made_tables.valid}")
|
logger.info(f"[DB MANAGEMENT] Results of migration is {made_tables}")
|
||||||
|
|
||||||
if not made_tables.valid:
|
if not migration.valid:
|
||||||
close_session()
|
db_version_you_have = 0
|
||||||
custom_error = "Could not Migrate the Database version, please delete the database. You will NOT lose profiles, this is the public data."
|
failed_migration(db_version_you_have)
|
||||||
from gui.v2.ui.popups.Database_version import show_recovery_dialog
|
# close_session()
|
||||||
choice = show_recovery_dialog({"message": custom_error, "db_version": 0, "status": "cant_make"})
|
# custom_error = "Could not Migrate the Database version, please delete the database. You will NOT lose profiles, this is the public data."
|
||||||
sys.exit()
|
# from gui.v2.ui.popups.Database_version import show_recovery_dialog
|
||||||
|
# choice = show_recovery_dialog({"message": custom_error, "db_version": 0, "status": "cant_make"})
|
||||||
|
# sys.exit()
|
||||||
|
|
||||||
# ASSUME TABLES CREATED
|
# ASSUME TABLES CREATED
|
||||||
logger.info("[DB MANAGEMENT] Tables successfully made or initialized if pre-existing")
|
logger.info("[DB MANAGEMENT] Tables successfully made or initialized if pre-existing")
|
||||||
|
|
@ -139,9 +153,15 @@ if is_compatable:
|
||||||
force_sync = True
|
force_sync = True
|
||||||
else:
|
else:
|
||||||
logger.info(f"[DB MANAGEMENT] Launcher is now passing it off to launch the main GUI window WITHOUT force sync..")
|
logger.info(f"[DB MANAGEMENT] Launcher is now passing it off to launch the main GUI window WITHOUT force sync..")
|
||||||
|
if not migration_happened:
|
||||||
|
force_sync = False
|
||||||
|
|
||||||
|
# make sure we declared it:
|
||||||
|
if 'force_sync' not in globals():
|
||||||
force_sync = False
|
force_sync = False
|
||||||
|
|
||||||
# Start GUI either way:
|
# Start GUI either way:
|
||||||
|
logger.info(f"[DB MANAGEMENT] Starting GUI..")
|
||||||
start_ui(force_sync)
|
start_ui(force_sync)
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue