优化安装数据库

This commit is contained in:
2026-04-01 14:08:45 +08:00
parent dc51b63e5e
commit 9058fa29fb
2 changed files with 108 additions and 0 deletions

View File

@@ -50,4 +50,19 @@ Config::load($baseDir . '/config', ['route', 'middleware', 'process', 'server',
$thinkorm = array_replace_recursive(config('thinkorm', []), config('think-orm', []));
if (!empty($thinkorm)) {
support\think\Db::setConfig($thinkorm);
// Webman DbManager 使用连接池且忽略 force安装向导在同进程内迁移时若不清理会沿用旧前缀连接
// 导致 Phinx 已建带前缀表而 Db::name() 仍查无前缀表(如 menu_rule 不存在)。
if (class_exists(\Webman\ThinkOrm\DbManager::class)) {
$ref = new \ReflectionClass(\Webman\ThinkOrm\DbManager::class);
if ($ref->hasProperty('pools')) {
$poolsProp = $ref->getProperty('pools');
$poolsProp->setAccessible(true);
$poolsProp->setValue(null, []);
}
}
if (class_exists(\Webman\Context::class)) {
foreach (array_keys($thinkorm['connections'] ?? []) as $connName) {
\Webman\Context::set('think-orm.connections.' . $connName, null);
}
}
}