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 @@ -16,7 +16,7 @@ const botViewer = createScriptViewer(bots.commbot.userID); -const migrations: $ReadOnlyMap Promise> = new Map([ +const migrations: $ReadOnlyMap Promise> = new Map([ [ 0, async () => { @@ -466,6 +466,17 @@ } }, ], + [ + 39, + () => + 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 @@ -306,10 +306,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),