mirror of
https://github.com/tiennm99/coolify.git
synced 2026-08-06 04:23:04 +00:00
fix(seeding): ensure root user joins root team
Create the root team before production seeding depends on it, reuse the existing root team when creating root users, and cover the production seeder flow with a feature test.
This commit is contained in:
@@ -98,8 +98,18 @@ class User extends Authenticatable implements SendsEmail
|
||||
$team['id'] = 0;
|
||||
$team['name'] = 'Root Team';
|
||||
}
|
||||
$new_team = $user->id === 0 ? Team::find(0) : null;
|
||||
|
||||
if ($new_team !== null) {
|
||||
$new_team->forceFill($team);
|
||||
$new_team->save();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$new_team = (new Team)->forceFill($team);
|
||||
$new_team->save();
|
||||
|
||||
$user->teams()->attach($new_team, ['role' => 'owner']);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user