Commit cc0a509a authored by Ronan's avatar Ronan

feat(MainDb): add an `events` module with 1.0.0 version

parent a3325dbd
......@@ -82,6 +82,9 @@ void l_assert (const char *condition, const char *file, int line);
#define L_UNLIKELY(EXPRESSION) EXPRESSION
#endif
// Define an integer version like: 0xXXYYZZ, XX=MAJOR, YY=MINOR, and ZZ=PATCH.
#define L_VERSION(MAJOR, MINOR, PATCH) (((MAJOR) << 16) | ((MINOR) << 8) | (PATCH))
class BaseObject;
class BaseObjectPrivate;
class ClonableObject;
......
......@@ -147,6 +147,13 @@ private:
void invalidConferenceEventsFromQuery (const std::string &query, long long chatRoomId);
// ---------------------------------------------------------------------------
// Versions.
// ---------------------------------------------------------------------------
unsigned int getModuleVersion (const std::string &name);
void updateModuleVersion (const std::string &name, unsigned int version);
L_DECLARE_PUBLIC(MainDb);
};
......
......@@ -41,6 +41,8 @@
#include "main-db-key-p.h"
#include "main-db-p.h"
#define DB_MODULE_VERSION_EVENTS L_VERSION(1, 0, 0)
// =============================================================================
// See: http://soci.sourceforge.net/doc/3.2/exchange.html
......@@ -1019,6 +1021,22 @@ static constexpr string &blobToString (string &in) {
}
}
// -----------------------------------------------------------------------------
unsigned int MainDbPrivate::getModuleVersion (const string &name) {
soci::session *session = dbSession.getBackendSession<soci::session>();
unsigned int version;
*session << "SELECT version FROM db_module_version WHERE name = :name", soci::into(version), soci::use(name);
return session->got_data() ? version : 0;
}
void MainDbPrivate::updateModuleVersion (const string &name, unsigned int version) {
soci::session *session = dbSession.getBackendSession<soci::session>();
*session << "REPLACE INTO db_module_version (name, version) VALUES (:name, :version)",
soci::use(name), soci::use(version);
}
// -----------------------------------------------------------------------------
void MainDb::init () {
......@@ -1310,6 +1328,8 @@ static constexpr string &blobToString (string &in) {
" name" + varcharPrimaryKeyStr(16) + ","
" version INT UNSIGNED NOT NULL"
") " + charset;
d->updateModuleVersion("events", DB_MODULE_VERSION_EVENTS);
}
bool MainDb::addEvent (const shared_ptr<EventLog> &eventLog) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment