+ else {
+ // Mark as successful
+ setSchemaVersionUpgradeStep(queryResource.queryFilename);
+ }
+ }
+
+ if (resumingUpgrade) {
+ // Something went wrong and the last successful SQL query to resume from couldn't be
+ // found.
+ // 1. The storage of successful query glitched, or the database was manually changed
+ // 2. Quassel changed the filenames of upgrade queries, and the local Quassel core
+ // version was replaced during an interrupted schema upgrade
+ //
+ // Both are unlikely, but it's a good idea to handle it anyways.
+
+ qCritical() << qPrintable(QString("Unable to resume interrupted upgrade in Logging "
+ "Backend! Missing upgrade step in schema version %1 "
+ "(expected step: %2)")
+ .arg(QString::number(ver), previousLaunchUpgradeStep));
+ return false;
+ }
+
+ // Update the schema version for each intermediate step and mark the step as done. This
+ // ensures that any interrupted upgrades have a greater chance of resuming correctly after
+ // core restart.
+ //
+ // Almost all databases make single queries atomic (fully works or fully fails, no partial),
+ // and with many of the longest migrations being a single query, this makes upgrade
+ // interruptions much more likely to leave the database in a valid intermediate schema
+ // version.
+ if (!updateSchemaVersion(ver, true)) {
+ // Updating the schema version failed, bail out
+ qCritical() << "Unable to upgrade Logging Backend! Setting schema version" << ver << "failed.";
+ return false;