MCPcopy Create free account
hub / github.com/CommE2E/comm / migrate

Method migrate

native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp:32–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30namespace comm {
31
32void SQLiteQueryExecutor::migrate() const {
33 this->connectionManager->validateEncryption();
34
35 std::stringstream db_path;
36 db_path << "db path: " << this->connectionManager->getSQLiteFilePath()
37 << std::endl;
38 Logger::log(db_path.str());
39
40 sqlite3 *db = this->connectionManager->getEphemeralConnection();
41
42 auto db_version = SQLiteUtils::getDatabaseVersion(db);
43 std::stringstream version_msg;
44 version_msg << "db version: " << db_version << std::endl;
45 Logger::log(version_msg.str());
46
47 if (db_version == 0) {
48 auto db_created = SQLiteSchema::setupDatabase(db);
49 if (!db_created) {
50 sqlite3_close(db);
51 Logger::log("Database structure creation error.");
52 throw std::runtime_error("Database structure creation error");
53 }
54 Logger::log("Database structure created.");
55
56 sqlite3_close(db);
57 return;
58 }
59
60 SQLiteSchema::migrate(db);
61 sqlite3_close(db);
62}
63
64SQLiteQueryExecutor::SQLiteQueryExecutor(
65 std::shared_ptr<SQLiteConnectionManager> connectionManager,

Callers 1

SQLiteQueryExecutorMethod · 0.95

Calls 5

getDatabaseVersionFunction · 0.85
migrateFunction · 0.85
getSQLiteFilePathMethod · 0.80
validateEncryptionMethod · 0.45

Tested by

no test coverage detected