fix: system_configs autoload 在 DB 不可用时不阻断启动
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user