From aef5dd61571bf56bf973136202a94b8dfd6730c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=87=8A=E5=BC=A6=E5=87=9D=E7=BB=9D?= <42119608+Goodjooy@users.noreply.github.com> Date: Tue, 15 Oct 2024 02:32:49 +0800 Subject: [PATCH] fix(sql): don't panic on missing migration when preload is enabled (#1932) Co-authored-by: Fabian-Lars --- plugins/sql/src/lib.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/sql/src/lib.rs b/plugins/sql/src/lib.rs index ec9362bf..f66137b8 100644 --- a/plugins/sql/src/lib.rs +++ b/plugins/sql/src/lib.rs @@ -145,7 +145,9 @@ impl Builder { for db in config.preload { let pool = DbPool::connect(&db, app).await?; - if let Some(migrations) = self.migrations.as_mut().unwrap().remove(&db) { + if let Some(migrations) = + self.migrations.as_mut().and_then(|mm| mm.remove(&db)) + { let migrator = Migrator::new(migrations).await?; pool.migrate(&migrator).await?; }