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
|
||||
# ============================================================================
|
||||
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):
|
||||
"""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!")
|
||||
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:
|
||||
logger.info(f"[DB MANAGEMENT] We are dealing with a legacy database, we need to transition the user.")
|
||||
|
||||
# shut down db connection
|
||||
close_session()
|
||||
migration = migrate_sql()
|
||||
|
||||
logger.info(f"[DB MANAGEMENT] Migration result is {migration.valid}.")
|
||||
if migration.valid:
|
||||
migration_happened = True
|
||||
force_sync = True
|
||||
else:
|
||||
# THEN DISPLAY CHOICES AND RECOVERY UI
|
||||
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."
|
||||
db_version_you_have = "Old System"
|
||||
recovery_dialog(custom_error, db_version_you_have)
|
||||
sys.exit()
|
||||
failed_migration(db_version_you_have)
|
||||
|
||||
# If they're still here, then if it's NOT a legacy version,
|
||||
|
||||
|
|
@ -112,15 +124,17 @@ if is_compatable:
|
|||
|
||||
except:
|
||||
logger.info(f"[DB MANAGEMENT] create ALL tables failed. Running migrations...")
|
||||
made_tables = migrate_sql()
|
||||
logger.info(f"[DB MANAGEMENT] Results of migration is {made_tables.valid}")
|
||||
migration = migrate_sql()
|
||||
logger.info(f"[DB MANAGEMENT] Results of migration is {made_tables}")
|
||||
|
||||
if not made_tables.valid:
|
||||
close_session()
|
||||
custom_error = "Could not Migrate the Database version, please delete the database. You will NOT lose profiles, this is the public data."
|
||||
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()
|
||||
if not migration.valid:
|
||||
db_version_you_have = 0
|
||||
failed_migration(db_version_you_have)
|
||||
# close_session()
|
||||
# custom_error = "Could not Migrate the Database version, please delete the database. You will NOT lose profiles, this is the public data."
|
||||
# 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
|
||||
logger.info("[DB MANAGEMENT] Tables successfully made or initialized if pre-existing")
|
||||
|
|
@ -139,9 +153,15 @@ if is_compatable:
|
|||
force_sync = True
|
||||
else:
|
||||
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
|
||||
|
||||
# Start GUI either way:
|
||||
logger.info(f"[DB MANAGEMENT] Starting GUI..")
|
||||
start_ui(force_sync)
|
||||
|
||||
# ============================================================================
|
||||
|
|
|
|||
Loading…
Reference in a new issue