优化安装报错问题
This commit is contained in:
@@ -231,8 +231,17 @@ class InstallData extends AbstractMigration
|
||||
|
||||
public function menuRule(): void
|
||||
{
|
||||
if (!$this->hasTable('menu_rule')) return;
|
||||
$table = $this->table('menu_rule');
|
||||
// Install 迁移在已存在 admin_rule(旧版表名)时会跳过创建 menu_rule,此处需与之一致
|
||||
$ruleTable = null;
|
||||
if ($this->hasTable('menu_rule')) {
|
||||
$ruleTable = 'menu_rule';
|
||||
} elseif ($this->hasTable('admin_rule')) {
|
||||
$ruleTable = 'admin_rule';
|
||||
}
|
||||
if ($ruleTable === null) {
|
||||
return;
|
||||
}
|
||||
$table = $this->table($ruleTable);
|
||||
$rows = [
|
||||
[
|
||||
'id' => '1',
|
||||
@@ -1155,7 +1164,7 @@ class InstallData extends AbstractMigration
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
];
|
||||
$exist = Db::name('menu_rule')->where('id', 1)->value('id');
|
||||
$exist = Db::name($ruleTable)->where('id', 1)->value('id');
|
||||
if (!$exist) {
|
||||
$table->insert($rows)->saveData();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user