From fe2fe94dd82030275bec150af87b4ec6292511c6 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Sat, 31 Oct 2026 13:46:30 +0100 Subject: [PATCH] Pre-release migrations --- RNS/Storage.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/RNS/Storage.py b/RNS/Storage.py index 05299732..7cbd766d 100644 --- a/RNS/Storage.py +++ b/RNS/Storage.py @@ -262,11 +262,20 @@ class KnownDestinationsStore: ratchet BLOB NOT NULL, received REAL NOT NULL)""") - # Pre-release migrations, will be folded into finalized schema befor 1.6.0 release - if 0 < db_version < 2: self._conn.execute("ALTER TABLE known_destinations ADD COLUMN lr_cost REAL") - - self._conn.execute("PRAGMA user_version = 2") - self._conn.commit() + try: + # Pre-release migrations, will be folded into finalized schema before 1.6.0 release + if 0 < db_version < 2: self._conn.execute("ALTER TABLE known_destinations ADD COLUMN lr_cost REAL") + if 0 < db_version < 3: self._conn.execute("ALTER TABLE known_destinations ALTER COLUMN packet_hash DROP NOT NULL") + self._conn.execute("PRAGMA user_version = 3") + self._conn.commit() + except Exception as e: + import RNS + RNS.log(f"Pre-release database migration failed: {e}", RNS.LOG_CRITICAL) + RNS.log(f"You will need to remove the known_destinations.db* files from your storage directory", RNS.LOG_CRITICAL) + RNS.log(f"On the next instance start, the database will be rebuilt", RNS.LOG_CRITICAL) + RNS.log(f"Exiting now", RNS.LOG_CRITICAL) + time.sleep(1) + RNS.panic() def __entry_row(self, destination_hash, entry): stamp = entry[5] if len(entry) > 5 else None