From 29f80e6e4d698217933b7bd2df90c08162416d3f Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Mon, 26 Mar 2018 13:33:17 +0200 Subject: Don't just set the db version, only when we create the db first. --- common/storage/entitystore.cpp | 9 +++++++++ common/storage/entitystore.h | 2 ++ 2 files changed, 11 insertions(+) (limited to 'common/storage') diff --git a/common/storage/entitystore.cpp b/common/storage/entitystore.cpp index 7da7efa..6021344 100644 --- a/common/storage/entitystore.cpp +++ b/common/storage/entitystore.cpp @@ -158,6 +158,15 @@ EntityStore::EntityStore(const ResourceContext &context, const Log::Context &ctx } +void EntityStore::createIfMissing() +{ + if (!d->exists()) { + startTransaction(Sink::Storage::DataStore::ReadWrite); + Storage::DataStore::setDatabaseVersion(d->transaction, Sink::latestDatabaseVersion()); + commitTransaction(); + } +} + void EntityStore::startTransaction(Sink::Storage::DataStore::AccessMode accessMode) { SinkTraceCtx(d->logCtx) << "Starting transaction: " << accessMode; diff --git a/common/storage/entitystore.h b/common/storage/entitystore.h index 3eb0b7b..985e7f9 100644 --- a/common/storage/entitystore.h +++ b/common/storage/entitystore.h @@ -39,6 +39,8 @@ public: EntityStore(const ResourceContext &resourceContext, const Sink::Log::Context &); ~EntityStore() = default; + void createIfMissing(); + //Only the pipeline may call the following functions outside of tests bool add(const QByteArray &type, ApplicationDomain::ApplicationDomainType newEntity, bool replayToSource); bool modify(const QByteArray &type, const ApplicationDomain::ApplicationDomainType &diff, const QByteArrayList &deletions, bool replayToSource); -- cgit v1.2.3