comparison MySQL/Plugins/MySQLIndex.cpp @ 400:897253c21208 db-protobuf

support for labels in mysql
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 07 Apr 2023 15:43:42 +0200
parents 3d6886f3e5b3
children 91124cc8a8c7
comparison
equal deleted inserted replaced
399:19bd3ee1f0b3 400:897253c21208
293 SetGlobalIntegerProperty(manager, MISSING_SERVER_IDENTIFIER, Orthanc::GlobalProperty_DatabasePatchLevel, revision); 293 SetGlobalIntegerProperty(manager, MISSING_SERVER_IDENTIFIER, Orthanc::GlobalProperty_DatabasePatchLevel, revision);
294 294
295 t.Commit(); 295 t.Commit();
296 } 296 }
297 297
298 if (revision != 6) 298 if (revision == 6)
299 {
300 // Added new table "Labels" since release 5.0 to deal with
301 // labels that were introduced in Orthanc 1.12.0
302 DatabaseManager::Transaction t(manager, TransactionType_ReadWrite);
303
304 t.GetDatabaseTransaction().ExecuteMultiLines(
305 "CREATE TABLE Labels(id BIGINT NOT NULL,"
306 "label VARCHAR(64) NOT NULL,"
307 "PRIMARY KEY(id, label),"
308 "CONSTRAINT Labels1 FOREIGN KEY (id) REFERENCES Resources(internalId) ON DELETE CASCADE);"
309 "CREATE INDEX LabelsIndex1 ON Labels(id);"
310 "CREATE INDEX LabelsIndex2 ON Labels(label);");
311
312 revision = 7;
313 SetGlobalIntegerProperty(manager, MISSING_SERVER_IDENTIFIER, Orthanc::GlobalProperty_DatabasePatchLevel, revision);
314
315 t.Commit();
316 }
317
318 if (revision != 7)
299 { 319 {
300 LOG(ERROR) << "MySQL plugin is incompatible with database schema revision: " << revision; 320 LOG(ERROR) << "MySQL plugin is incompatible with database schema revision: " << revision;
301 throw Orthanc::OrthancException(Orthanc::ErrorCode_Database); 321 throw Orthanc::OrthancException(Orthanc::ErrorCode_Database);
302 } 322 }
303 } 323 }