summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--platform/default/mbgl/storage/offline_database.cpp10
-rw-r--r--test/storage/offline_database.test.cpp2
2 files changed, 7 insertions, 5 deletions
diff --git a/platform/default/mbgl/storage/offline_database.cpp b/platform/default/mbgl/storage/offline_database.cpp
index 8256912d39..a24c0cf912 100644
--- a/platform/default/mbgl/storage/offline_database.cpp
+++ b/platform/default/mbgl/storage/offline_database.cpp
@@ -652,11 +652,13 @@ OfflineDatabase::mergeDatabase(const std::string& sideDatabasePath) {
return unexpected<std::exception_ptr>(std::current_exception());
}
try {
- // Attaching an accessible path without a db file creates a new temporary
- //database and attaches it. Check for matching schema version.
+ // Support sideloaded databases at user_version = 6. Future schema version
+ // changes will need to implement migration paths for sideloaded databases at
+ // version 6.
auto sideUserVersion = static_cast<int>(getPragma<int64_t>("PRAGMA side.user_version"));
- if (sideUserVersion != 6) {
- throw std::runtime_error("Merge database does not match schema or has incorrect user_version");
+ const auto mainUserVersion = getPragma<int64_t>("PRAGMA user_version");
+ if (sideUserVersion < 6 || sideUserVersion != mainUserVersion) {
+ throw std::runtime_error("Merge database has incorrect user_version");
}
mapbox::sqlite::Transaction transaction(*db);
diff --git a/test/storage/offline_database.test.cpp b/test/storage/offline_database.test.cpp
index c9e3203abe..7511924d80 100644
--- a/test/storage/offline_database.test.cpp
+++ b/test/storage/offline_database.test.cpp
@@ -1277,7 +1277,7 @@ TEST(OfflineDatabase, MergeDatabaseWithInvalidPath) {
auto result = db.mergeDatabase(filename_sideload);
EXPECT_FALSE(result);
- EXPECT_EQ(1u, log.count({ EventSeverity::Error, Event::Database, -1, "Merge database does not match schema or has incorrect user_version" }));
+ EXPECT_EQ(1u, log.count({ EventSeverity::Error, Event::Database, -1, "Merge database has incorrect user_version" }));
EXPECT_EQ(0u, log.uncheckedCount());
}