fix: prevent overwriting existing webhook notification settings during migration

This commit is contained in:
Andras Bacsai 2025-11-25 15:40:45 +01:00
parent 477738dd2f
commit 3bdcc06838

View file

@ -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());
}