diff options
Diffstat (limited to 'common/storage')
-rw-r--r-- | common/storage/entitystore.cpp | 9 | ||||
-rw-r--r-- | common/storage/entitystore.h | 2 |
2 files changed, 11 insertions, 0 deletions
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 | |||
158 | 158 | ||
159 | } | 159 | } |
160 | 160 | ||
161 | void EntityStore::createIfMissing() | ||
162 | { | ||
163 | if (!d->exists()) { | ||
164 | startTransaction(Sink::Storage::DataStore::ReadWrite); | ||
165 | Storage::DataStore::setDatabaseVersion(d->transaction, Sink::latestDatabaseVersion()); | ||
166 | commitTransaction(); | ||
167 | } | ||
168 | } | ||
169 | |||
161 | void EntityStore::startTransaction(Sink::Storage::DataStore::AccessMode accessMode) | 170 | void EntityStore::startTransaction(Sink::Storage::DataStore::AccessMode accessMode) |
162 | { | 171 | { |
163 | SinkTraceCtx(d->logCtx) << "Starting transaction: " << accessMode; | 172 | 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: | |||
39 | EntityStore(const ResourceContext &resourceContext, const Sink::Log::Context &); | 39 | EntityStore(const ResourceContext &resourceContext, const Sink::Log::Context &); |
40 | ~EntityStore() = default; | 40 | ~EntityStore() = default; |
41 | 41 | ||
42 | void createIfMissing(); | ||
43 | |||
42 | //Only the pipeline may call the following functions outside of tests | 44 | //Only the pipeline may call the following functions outside of tests |
43 | bool add(const QByteArray &type, ApplicationDomain::ApplicationDomainType newEntity, bool replayToSource); | 45 | bool add(const QByteArray &type, ApplicationDomain::ApplicationDomainType newEntity, bool replayToSource); |
44 | bool modify(const QByteArray &type, const ApplicationDomain::ApplicationDomainType &diff, const QByteArrayList &deletions, bool replayToSource); | 46 | bool modify(const QByteArray &type, const ApplicationDomain::ApplicationDomainType &diff, const QByteArrayList &deletions, bool replayToSource); |