fix: prevent overwriting existing webhook notification settings during migration
This commit is contained in:
parent
477738dd2f
commit
3bdcc06838
1 changed files with 11 additions and 5 deletions
|
|
@ -45,9 +45,15 @@ public function up(): void
|
|||
DB::table('teams')->chunkById(100, function ($teams) {
|
||||
foreach ($teams as $team) {
|
||||
try {
|
||||
DB::table('webhook_notification_settings')->updateOrInsert(
|
||||
['team_id' => $team->id],
|
||||
[
|
||||
// Check if settings already exist for this team
|
||||
$exists = DB::table('webhook_notification_settings')
|
||||
->where('team_id', $team->id)
|
||||
->exists();
|
||||
|
||||
if (! $exists) {
|
||||
// Only insert if no settings exist - don't overwrite existing preferences
|
||||
DB::table('webhook_notification_settings')->insert([
|
||||
'team_id' => $team->id,
|
||||
'webhook_enabled' => false,
|
||||
'webhook_url' => null,
|
||||
'deployment_success_webhook_notifications' => false,
|
||||
|
|
@ -64,8 +70,8 @@ public function up(): void
|
|||
'server_unreachable_webhook_notifications' => true,
|
||||
'server_patch_webhook_notifications' => false,
|
||||
'traefik_outdated_webhook_notifications' => true,
|
||||
]
|
||||
);
|
||||
]);
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
Log::error('Error creating webhook notification settings for team '.$team->id.': '.$e->getMessage());
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue