mirror of
https://github.com/tiennm99/coolify.git
synced 2026-04-17 17:21:04 +00:00
fix: prevent overwriting existing webhook notification settings during migration
This commit is contained in:
@@ -45,9 +45,15 @@ return new class extends Migration
|
|||||||
DB::table('teams')->chunkById(100, function ($teams) {
|
DB::table('teams')->chunkById(100, function ($teams) {
|
||||||
foreach ($teams as $team) {
|
foreach ($teams as $team) {
|
||||||
try {
|
try {
|
||||||
DB::table('webhook_notification_settings')->updateOrInsert(
|
// Check if settings already exist for this team
|
||||||
['team_id' => $team->id],
|
$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_enabled' => false,
|
||||||
'webhook_url' => null,
|
'webhook_url' => null,
|
||||||
'deployment_success_webhook_notifications' => false,
|
'deployment_success_webhook_notifications' => false,
|
||||||
@@ -64,8 +70,8 @@ return new class extends Migration
|
|||||||
'server_unreachable_webhook_notifications' => true,
|
'server_unreachable_webhook_notifications' => true,
|
||||||
'server_patch_webhook_notifications' => false,
|
'server_patch_webhook_notifications' => false,
|
||||||
'traefik_outdated_webhook_notifications' => true,
|
'traefik_outdated_webhook_notifications' => true,
|
||||||
]
|
]);
|
||||||
);
|
}
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
Log::error('Error creating webhook notification settings for team '.$team->id.': '.$e->getMessage());
|
Log::error('Error creating webhook notification settings for team '.$team->id.': '.$e->getMessage());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user