Mercurial > hg > orthanc-databases
diff 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 |
line wrap: on
line diff
--- a/MySQL/Plugins/MySQLIndex.cpp Fri Apr 07 15:28:47 2023 +0200 +++ b/MySQL/Plugins/MySQLIndex.cpp Fri Apr 07 15:43:42 2023 +0200 @@ -295,7 +295,27 @@ t.Commit(); } - if (revision != 6) + if (revision == 6) + { + // Added new table "Labels" since release 5.0 to deal with + // labels that were introduced in Orthanc 1.12.0 + DatabaseManager::Transaction t(manager, TransactionType_ReadWrite); + + t.GetDatabaseTransaction().ExecuteMultiLines( + "CREATE TABLE Labels(id BIGINT NOT NULL," + "label VARCHAR(64) NOT NULL," + "PRIMARY KEY(id, label)," + "CONSTRAINT Labels1 FOREIGN KEY (id) REFERENCES Resources(internalId) ON DELETE CASCADE);" + "CREATE INDEX LabelsIndex1 ON Labels(id);" + "CREATE INDEX LabelsIndex2 ON Labels(label);"); + + revision = 7; + SetGlobalIntegerProperty(manager, MISSING_SERVER_IDENTIFIER, Orthanc::GlobalProperty_DatabasePatchLevel, revision); + + t.Commit(); + } + + if (revision != 7) { LOG(ERROR) << "MySQL plugin is incompatible with database schema revision: " << revision; throw Orthanc::OrthancException(Orthanc::ErrorCode_Database);