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 @@ -490,6 +490,20 @@ `, ), ], + [ + 42, + async () => { + await dbQuery(SQL` + UPDATE threads + SET pinned_count = ( + SELECT COUNT(*) + FROM messages + WHERE messages.thread = threads.id + AND messages.pinned = 1 + ); + `); + }, + ], ]); const newDatabaseVersion: number = Math.max(...migrations.keys());