优化安装数据库
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user