diff --git a/keyserver/src/database/migration-config.js b/keyserver/src/database/migration-config.js --- a/keyserver/src/database/migration-config.js +++ b/keyserver/src/database/migration-config.js @@ -479,6 +479,17 @@ `, ), ], + [ + 41, + () => + dbQuery( + SQL` + ALTER TABLE memberships + DROP INDEX user, + ADD KEY user_role_thread (user, role, thread) + `, + ), + ], ]); const newDatabaseVersion: number = Math.max(...migrations.keys()); diff --git a/keyserver/src/database/setup-db.js b/keyserver/src/database/setup-db.js --- a/keyserver/src/database/setup-db.js +++ b/keyserver/src/database/setup-db.js @@ -308,10 +308,9 @@ ADD PRIMARY KEY (id); ALTER TABLE memberships - ADD UNIQUE KEY thread_user (thread,user) USING BTREE, - ADD KEY role (role) USING BTREE; - - ALTER TABLE memberships ADD INDEX user (user); + ADD UNIQUE KEY thread_user (thread, user) USING BTREE, + ADD KEY role (role) USING BTREE, + ADD KEY user_role_thread (user, role, thread); ALTER TABLE messages ADD PRIMARY KEY (id),