diff --git a/app/Console/Migrations/V20250110191618.php b/app/Console/Migrations/V20250110191618.php new file mode 100644 index 00000000..9826e4cd --- /dev/null +++ b/app/Console/Migrations/V20250110191618.php @@ -0,0 +1,41 @@ +handleRootUserBalance(); + } + + /** + * 之前migration初始化root账号缺少user_balance数据 + */ + protected function handleRootUserBalance() + { + $userId = 10000; + + $userRepo = new UserRepo(); + + $userBalance = $userRepo->findUserBalance($userId); + + if ($userBalance) return; + + $userBalance = new UserBalance(); + + $userBalance->user_id = $userId; + + $userBalance->create(); + } + +} diff --git a/db/migrations/20210403184518.php b/db/migrations/20210403184518.php index 47ce2604..148bc846 100644 --- a/db/migrations/20210403184518.php +++ b/db/migrations/20210403184518.php @@ -45,6 +45,13 @@ final class V20210403184518 extends AbstractMigration ]; $this->table('kg_user')->insert($user)->saveData(); + + $balance = [ + 'user_id' => $account['id'], + 'create_time' => $now, + ]; + + $this->table('kg_user_balance')->insert($balance)->saveData(); } protected function initRoleData()