From 3bdcc06838cb7f291a5bc61770220a33a790b034 Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Tue, 25 Nov 2025 15:40:45 +0100 Subject: [PATCH] fix: prevent overwriting existing webhook notification settings during migration --- ...reate_webhook_notification_settings_table.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/database/migrations/2025_11_25_000001_create_webhook_notification_settings_table.php b/database/migrations/2025_11_25_000001_create_webhook_notification_settings_table.php index eb1653238..df620bd6e 100644 --- a/database/migrations/2025_11_25_000001_create_webhook_notification_settings_table.php +++ b/database/migrations/2025_11_25_000001_create_webhook_notification_settings_table.php @@ -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()); }