From 9eb1e90bbe1118edf766f53b5ed8718a8a61ea12 Mon Sep 17 00:00:00 2001 From: Pascal Fischer Date: Wed, 15 Nov 2023 11:21:59 +0100 Subject: [PATCH] refactor activity get queries to only add comment --- management/server/activity/sqlite/sqlite.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/management/server/activity/sqlite/sqlite.go b/management/server/activity/sqlite/sqlite.go index 1eefa573a..b54db5276 100644 --- a/management/server/activity/sqlite/sqlite.go +++ b/management/server/activity/sqlite/sqlite.go @@ -60,6 +60,14 @@ const ( insertQuery = "INSERT INTO events(activity, timestamp, initiator_id, target_id, account_id, meta) " + "VALUES(?, ?, ?, ?, ?, ?)" + /* + TODO: + The insert should avoid duplicated IDs in the table. So the query should be changes to something like: + `INSERT INTO deleted_users(id, email, name) VALUES(?, ?, ?) ON CONFLICT (id) DO UPDATE SET email = EXCLUDED.email, name = EXCLUDED.name;` + For this to work we have to set the id column as primary key. But this is not possible because the id column is not unique + and some selfhosted deployments might have duplicates already so we need to clean the table first. + */ + insertDeleteUserQuery = `INSERT INTO deleted_users(id, email, name) VALUES(?, ?, ?)` fallbackName = "unknown"