From 3484402ea870150e3b72f873340d45ca2afe57b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Sun, 15 Mar 2026 20:08:46 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20system=5Fconfigs=20autoload=20=E5=9C=A8?= =?UTF-8?q?=20DB=20=E4=B8=8D=E5=8F=AF=E7=94=A8=E6=97=B6=E4=B8=8D=E9=98=BB?= =?UTF-8?q?=E6=96=AD=E5=90=AF=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Providers/AppServiceProvider.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 90afa04..4c86a22 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -26,7 +26,13 @@ class AppServiceProvider extends ServiceProvider // 安全阀: // - 在测试/首次安装阶段,可能尚未执行迁移;此时 system_configs 表不存在,必须跳过。 // - 任意配置项解析失败(如 JSON 格式错误)也不应阻断应用启动。 - if (! Schema::hasTable('system_configs')) { + // 若数据库连接不可用(例如本地 mysql 未启动 / CI 环境),Schema::hasTable() 会直接抛异常。 + // 这里加一层 try/catch,确保“治理配置加载”不会阻断应用启动。 + try { + if (! Schema::hasTable('system_configs')) { + return; + } + } catch (\Throwable $e) { return; }