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 @@ -466,6 +466,15 @@ } }, ], + [ + 39, + async () => { + await dbQuery(SQL` + ALTER TABLE roles + ADD UNIQUE KEY thread_name (thread, name); + `); + }, + ], ]); 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 @@ -339,7 +339,8 @@ ALTER TABLE roles ADD PRIMARY KEY (id), - ADD KEY thread (thread); + ADD KEY thread (thread), + ADD UNIQUE KEY thread_name (thread, name); ALTER TABLE sessions ADD PRIMARY KEY (id),