From 784f35ebfa8568593812683b5fa399ca87af2d6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=B0spik?= Date: Mon, 13 Jul 2026 23:40:15 +0300 Subject: [PATCH] fix: migration script would panic on fresh installations since it couldn't find invites collection (#820) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: İspik --- .../admin_migrations/ops/mongodb/scripts.rs | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/crates/core/database/src/models/admin_migrations/ops/mongodb/scripts.rs b/crates/core/database/src/models/admin_migrations/ops/mongodb/scripts.rs index e7c4ea89..2da6e9e6 100644 --- a/crates/core/database/src/models/admin_migrations/ops/mongodb/scripts.rs +++ b/crates/core/database/src/models/admin_migrations/ops/mongodb/scripts.rs @@ -1478,16 +1478,22 @@ pub async fn run_migrations(db: &MongoDb, revision: i32) -> i32 { if revision <= 50 { info!("Running migration [revision 50 / 13-04-2026]: Rename invites collection to account_invites"); - db.db() + let result = db.db() .client() .database("admin") .run_command(doc! { - "renameCollection": "revolt.invites", - "to": "revolt.account_invites", - "dropTarget": true - }) - .await - .unwrap(); + "renameCollection": "revolt.invites", + "to": "revolt.account_invites", + "dropTarget": true + }) + .await; + + if let Err(e) = result { + // NamespaceNotFound (26) = source collection doesn't exist, safe to ignore + if !matches!(e.kind.as_ref(), mongodb::error::ErrorKind::Command(ce) if ce.code == 26) { + panic!("Failed to rename invites collection: {e}"); + } + } } if revision >= 51 {