comparison 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
comparison
equal deleted inserted replaced
365:7671fa7f099e 366:cd9521e04249
143 { 143 {
144 revision = 1; 144 revision = 1;
145 SetGlobalIntegerProperty(manager, MISSING_SERVER_IDENTIFIER, Orthanc::GlobalProperty_DatabasePatchLevel, revision); 145 SetGlobalIntegerProperty(manager, MISSING_SERVER_IDENTIFIER, Orthanc::GlobalProperty_DatabasePatchLevel, revision);
146 } 146 }
147 147
148 if (revision != 1) 148 // install customData
149 if (!LookupGlobalIntegerProperty(revision, manager, MISSING_SERVER_IDENTIFIER, Orthanc::GlobalProperty_DatabasePatchLevel)
150 || revision == 1)
151 {
152 std::string query;
153
154 Orthanc::EmbeddedResources::GetFileResource
155 (query, Orthanc::EmbeddedResources::SQLITE_INSTALL_CUSTOM_DATA);
156
157 t.GetDatabaseTransaction().ExecuteMultiLines(query);
158
159 revision = 2;
160 SetGlobalIntegerProperty(manager, MISSING_SERVER_IDENTIFIER, Orthanc::GlobalProperty_DatabasePatchLevel, revision);
161 }
162
163 if (revision != 2)
149 { 164 {
150 LOG(ERROR) << "SQLite plugin is incompatible with database schema revision: " << revision; 165 LOG(ERROR) << "SQLite plugin is incompatible with database schema revision: " << revision;
151 throw Orthanc::OrthancException(Orthanc::ErrorCode_Database); 166 throw Orthanc::OrthancException(Orthanc::ErrorCode_Database);
152 } 167 }
153 168