diff --git a/services/distributeddataservice/service/rdb/rdb_service_impl.cpp b/services/distributeddataservice/service/rdb/rdb_service_impl.cpp index c4123e29925d21a3569a41fcd9affee064ed5f8c..baaff4ef089394215779dd006c7c9b1b18899d40 100644 --- a/services/distributeddataservice/service/rdb/rdb_service_impl.cpp +++ b/services/distributeddataservice/service/rdb/rdb_service_impl.cpp @@ -1231,8 +1231,21 @@ int32_t RdbServiceImpl::RdbStatic::OnAppUpdate(const std::string &bundleName, in std::string prefix = Database::GetPrefix({std::to_string(user), "default", bundleName}); std::vector dataBase; if (MetaDataManager::GetInstance().LoadMeta(prefix, dataBase, true)) { - for (const auto &dataBase : dataBase) { - MetaDataManager::GetInstance().DelMeta(dataBase.GetKey(), true); + for (const auto &database : dataBase) { + MetaDataManager::GetInstance().DelMeta(database.GetKey(), true); + ZLOGD("del metadata store is: %{public}s; user is: %{public}s; bundleName is: %{public}s", + Anonymous::Change(database.name).c_str(), database.user.c_str(), database.bundleName.c_str()); + StoreMetaData meta; + meta.user = database.user; + meta.deviceId = database.deviceId; + meta.storeId = database.name; + meta.bundleName = bundleName; + Database base; + if (RdbSchemaConfig::GetDistributedSchema(meta, base) && !base.name.empty() && !base.bundleName.empty()) { + MetaDataManager::GetInstance().SaveMeta(base.GetKey(), base, true); + ZLOGD("save metadata store is: %{public}s; user is: %{public}s; bundleName is: %{public}s", + Anonymous::Change(base.name).c_str(), base.user.c_str(), base.bundleName.c_str()); + } } } return CloseStore(bundleName, user, index);