comparison PostgreSQL/Plugins/PostgreSQLIndex.cpp @ 266:cc7af42d4f23

Store revisions for metadata and attachments in PostgreSQL
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 20 Apr 2021 17:41:44 +0200
parents 29d2b76516f6
children 3a52e27a2d80
comparison
equal deleted inserted replaced
265:cd73e34d5411 266:cc7af42d4f23
274 { 274 {
275 t.GetDatabaseTransaction().ExecuteMultiLines("CREATE TABLE ServerProperties(server VARCHAR(64) NOT NULL, " 275 t.GetDatabaseTransaction().ExecuteMultiLines("CREATE TABLE ServerProperties(server VARCHAR(64) NOT NULL, "
276 "property INTEGER, value TEXT, PRIMARY KEY(server, property))"); 276 "property INTEGER, value TEXT, PRIMARY KEY(server, property))");
277 } 277 }
278 278
279 /**
280 * PostgreSQL 9.5: "Adding a column with a default requires
281 * updating each row of the table (to store the new column
282 * value). However, if no default is specified, PostgreSQL is
283 * able to avoid the physical update." => We set no default
284 * for performance (older entries will be NULL)
285 * https://www.postgresql.org/docs/9.5/ddl-alter.html
286 **/
287 if (!db.DoesColumnExist("Metadata", "revision"))
288 {
289 t.GetDatabaseTransaction().ExecuteMultiLines("ALTER TABLE Metadata ADD COLUMN revision INTEGER");
290 }
291
292 if (!db.DoesColumnExist("AttachedFiles", "revision"))
293 {
294 t.GetDatabaseTransaction().ExecuteMultiLines("ALTER TABLE AttachedFiles ADD COLUMN revision INTEGER");
295 }
296
279 t.Commit(); 297 t.Commit();
280 } 298 }
281 } 299 }
282 } 300 }
283 301