comparison SQLite/Plugins/SQLiteIndex.cpp @ 417:15bfd9a76f8d pg-transactions

merge
author Alain Mazy <am@osimis.io>
date Fri, 23 Jun 2023 14:26:58 +0200
parents 91124cc8a8c7
children ecd0b719cff5
comparison
equal deleted inserted replaced
370:d2b5d9c92214 417:15bfd9a76f8d
1 /** 1 /**
2 * Orthanc - A Lightweight, RESTful DICOM Store 2 * Orthanc - A Lightweight, RESTful DICOM Store
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
4 * Department, University Hospital of Liege, Belgium 4 * Department, University Hospital of Liege, Belgium
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium 5 * Copyright (C) 2017-2023 Osimis S.A., Belgium
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium 6 * Copyright (C) 2021-2023 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
7 * 7 *
8 * This program is free software: you can redistribute it and/or 8 * This program is free software: you can redistribute it and/or
9 * modify it under the terms of the GNU Affero General Public License 9 * modify it under the terms of the GNU Affero General Public License
10 * as published by the Free Software Foundation, either version 3 of 10 * as published by the Free Software Foundation, either version 3 of
11 * the License, or (at your option) any later version. 11 * the License, or (at your option) any later version.
83 83
84 return new Factory(path_, fast_); 84 return new Factory(path_, fast_);
85 } 85 }
86 86
87 87
88 void SQLiteIndex::ConfigureDatabase(DatabaseManager& manager) 88 void SQLiteIndex::ConfigureDatabase(DatabaseManager& manager,
89 bool hasIdentifierTags,
90 const std::list<IdentifierTag>& identifierTags)
89 { 91 {
90 uint32_t expectedVersion = 6; 92 uint32_t expectedVersion = 6;
91 93
92 if (GetContext()) // "GetContext()" can possibly be NULL in the unit tests 94 if (GetContext()) // "GetContext()" can possibly be NULL in the unit tests
93 { 95 {
160 162
161 if (!t.GetDatabaseTransaction().DoesTableExist("ServerProperties")) 163 if (!t.GetDatabaseTransaction().DoesTableExist("ServerProperties"))
162 { 164 {
163 t.GetDatabaseTransaction().ExecuteMultiLines("CREATE TABLE ServerProperties(server TEXT, " 165 t.GetDatabaseTransaction().ExecuteMultiLines("CREATE TABLE ServerProperties(server TEXT, "
164 "property INTEGER, value TEXT, PRIMARY KEY(server, property))"); 166 "property INTEGER, value TEXT, PRIMARY KEY(server, property))");
167 }
168
169 t.Commit();
170 }
171
172 {
173 DatabaseManager::Transaction t(manager, TransactionType_ReadWrite);
174
175 if (!t.GetDatabaseTransaction().DoesTableExist("Labels"))
176 {
177 t.GetDatabaseTransaction().ExecuteMultiLines(
178 "CREATE TABLE Labels("
179 " id INTEGER REFERENCES Resources(internalId) ON DELETE CASCADE,"
180 " label TEXT NOT NULL,"
181 " PRIMARY KEY(id, label));"
182 "CREATE INDEX LabelsIndex1 ON Labels(id);"
183 "CREATE INDEX LabelsIndex2 ON Labels(label);");
165 } 184 }
166 185
167 t.Commit(); 186 t.Commit();
168 } 187 }
169 } 188 }