Mercurial > hg > orthanc-databases
diff SQLite/Plugins/SQLiteIndex.cpp @ 366:cd9521e04249 attach-custom-data
DatabaseBackendAdapterV4: added support for customData + revision when not already done
author | Alain Mazy <am@osimis.io> |
---|---|
date | Thu, 15 Sep 2022 18:12:34 +0200 |
parents | d663d9e44f8d |
children | f18e46d7dbf8 |
line wrap: on
line diff
--- a/SQLite/Plugins/SQLiteIndex.cpp Tue Jul 05 08:44:26 2022 +0200 +++ b/SQLite/Plugins/SQLiteIndex.cpp Thu Sep 15 18:12:34 2022 +0200 @@ -145,7 +145,22 @@ SetGlobalIntegerProperty(manager, MISSING_SERVER_IDENTIFIER, Orthanc::GlobalProperty_DatabasePatchLevel, revision); } - if (revision != 1) + // install customData + if (!LookupGlobalIntegerProperty(revision, manager, MISSING_SERVER_IDENTIFIER, Orthanc::GlobalProperty_DatabasePatchLevel) + || revision == 1) + { + std::string query; + + Orthanc::EmbeddedResources::GetFileResource + (query, Orthanc::EmbeddedResources::SQLITE_INSTALL_CUSTOM_DATA); + + t.GetDatabaseTransaction().ExecuteMultiLines(query); + + revision = 2; + SetGlobalIntegerProperty(manager, MISSING_SERVER_IDENTIFIER, Orthanc::GlobalProperty_DatabasePatchLevel, revision); + } + + if (revision != 2) { LOG(ERROR) << "SQLite plugin is incompatible with database schema revision: " << revision; throw Orthanc::OrthancException(Orthanc::ErrorCode_Database);