comparison MySQL/Plugins/MySQLIndex.cpp @ 221:73cc85f3d9c1

implementation of the "serverIdentifier" information for global properties
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 30 Mar 2021 10:40:34 +0200
parents ee5858d438dc
children 94c9908e6aca
comparison
equal deleted inserted replaced
220:492aa3edf572 221:73cc85f3d9c1
139 if (!db->DoesTriggerExist(t, "PatientAdded")) 139 if (!db->DoesTriggerExist(t, "PatientAdded"))
140 { 140 {
141 ThrowCannotCreateTrigger(); 141 ThrowCannotCreateTrigger();
142 } 142 }
143 143
144 if (!LookupGlobalIntegerProperty(version, *db, t, Orthanc::GlobalProperty_DatabaseSchemaVersion)) 144 if (!LookupGlobalIntegerProperty(version, *db, t, MISSING_SERVER_IDENTIFIER, Orthanc::GlobalProperty_DatabaseSchemaVersion))
145 { 145 {
146 SetGlobalIntegerProperty(*db, t, Orthanc::GlobalProperty_DatabaseSchemaVersion, expectedVersion); 146 SetGlobalIntegerProperty(*db, t, MISSING_SERVER_IDENTIFIER, Orthanc::GlobalProperty_DatabaseSchemaVersion, expectedVersion);
147 SetGlobalIntegerProperty(*db, t, Orthanc::GlobalProperty_DatabasePatchLevel, 1); 147 SetGlobalIntegerProperty(*db, t, MISSING_SERVER_IDENTIFIER, Orthanc::GlobalProperty_DatabasePatchLevel, 1);
148 version = expectedVersion; 148 version = expectedVersion;
149 } 149 }
150 150
151 if (version != 6) 151 if (version != 6)
152 { 152 {
160 int revision = 0; 160 int revision = 0;
161 161
162 { 162 {
163 MySQLTransaction t(*db, TransactionType_ReadWrite); 163 MySQLTransaction t(*db, TransactionType_ReadWrite);
164 164
165 if (!LookupGlobalIntegerProperty(revision, *db, t, Orthanc::GlobalProperty_DatabasePatchLevel)) 165 if (!LookupGlobalIntegerProperty(revision, *db, t, MISSING_SERVER_IDENTIFIER, Orthanc::GlobalProperty_DatabasePatchLevel))
166 { 166 {
167 revision = 1; 167 revision = 1;
168 SetGlobalIntegerProperty(*db, t, Orthanc::GlobalProperty_DatabasePatchLevel, revision); 168 SetGlobalIntegerProperty(*db, t, MISSING_SERVER_IDENTIFIER, Orthanc::GlobalProperty_DatabasePatchLevel, revision);
169 } 169 }
170 170
171 t.Commit(); 171 t.Commit();
172 } 172 }
173 173
180 // store up to 4GB: 180 // store up to 4GB:
181 // https://stackoverflow.com/a/13932834/881731 181 // https://stackoverflow.com/a/13932834/881731
182 db->Execute("ALTER TABLE GlobalProperties MODIFY value LONGTEXT", false); 182 db->Execute("ALTER TABLE GlobalProperties MODIFY value LONGTEXT", false);
183 183
184 revision = 2; 184 revision = 2;
185 SetGlobalIntegerProperty(*db, t, Orthanc::GlobalProperty_DatabasePatchLevel, revision); 185 SetGlobalIntegerProperty(*db, t, MISSING_SERVER_IDENTIFIER, Orthanc::GlobalProperty_DatabasePatchLevel, revision);
186 186
187 t.Commit(); 187 t.Commit();
188 } 188 }
189 189
190 if (revision == 2) 190 if (revision == 2)
202 { 202 {
203 ThrowCannotCreateTrigger(); 203 ThrowCannotCreateTrigger();
204 } 204 }
205 205
206 revision = 3; 206 revision = 3;
207 SetGlobalIntegerProperty(*db, t, Orthanc::GlobalProperty_DatabasePatchLevel, revision); 207 SetGlobalIntegerProperty(*db, t, MISSING_SERVER_IDENTIFIER, Orthanc::GlobalProperty_DatabasePatchLevel, revision);
208 208
209 t.Commit(); 209 t.Commit();
210 } 210 }
211 211
212 if (revision == 3) 212 if (revision == 3)
219 // large amount of metadata. 219 // large amount of metadata.
220 // http://book.orthanc-server.com/faq/features.html#central-registry-of-metadata-and-attachments 220 // http://book.orthanc-server.com/faq/features.html#central-registry-of-metadata-and-attachments
221 db->Execute("ALTER TABLE Metadata MODIFY value LONGTEXT", false); 221 db->Execute("ALTER TABLE Metadata MODIFY value LONGTEXT", false);
222 222
223 revision = 4; 223 revision = 4;
224 SetGlobalIntegerProperty(*db, t, Orthanc::GlobalProperty_DatabasePatchLevel, revision); 224 SetGlobalIntegerProperty(*db, t, MISSING_SERVER_IDENTIFIER, Orthanc::GlobalProperty_DatabasePatchLevel, revision);
225 225
226 t.Commit(); 226 t.Commit();
227 } 227 }
228 228
229 if (revision == 4) 229 if (revision == 4)
236 Orthanc::EmbeddedResources::GetFileResource 236 Orthanc::EmbeddedResources::GetFileResource
237 (query, Orthanc::EmbeddedResources::MYSQL_CREATE_INSTANCE); 237 (query, Orthanc::EmbeddedResources::MYSQL_CREATE_INSTANCE);
238 db->Execute(query, true); 238 db->Execute(query, true);
239 239
240 revision = 5; 240 revision = 5;
241 SetGlobalIntegerProperty(*db, t, Orthanc::GlobalProperty_DatabasePatchLevel, revision); 241 SetGlobalIntegerProperty(*db, t, MISSING_SERVER_IDENTIFIER, Orthanc::GlobalProperty_DatabasePatchLevel, revision);
242 242
243 t.Commit(); 243 t.Commit();
244 } 244 }
245 245
246 if (revision != 5) 246 if (revision != 5)