- foreach(QString queryString, upgradeQueries(ver)) {
- QSqlQuery query = db.exec(queryString);
+ foreach (auto queryResource, upgradeQueries(ver)) {
+ if (resumingUpgrade) {
+ // An upgrade was interrupted. Check if this matches the the last successful query.
+ if (previousLaunchUpgradeStep == queryResource.queryFilename) {
+ // Found the matching query!
+ qInfo() << qPrintable(QString("Resuming interrupted upgrade for schema version %1 (last step: %2)")
+ .arg(QString::number(ver), previousLaunchUpgradeStep));
+
+ // Stop searching for queries
+ resumingUpgrade = false;
+ // Continue past the previous query with the next not-yet-tried query
+ continue;
+ }
+ else {
+ // Not yet matched, keep looking
+ continue;
+ }
+ }
+
+ // Run the upgrade query
+ QSqlQuery query = db.exec(queryResource.queryString);