mirror of
https://github.com/tiennm99/coolify.git
synced 2026-04-17 19:21:36 +00:00
fix: update webhook notification settings migration to use updateOrInsert and add logging
This commit is contained in:
@@ -24,6 +24,8 @@ class WebhookNotificationSettings extends Model
|
|||||||
'backup_failure_webhook_notifications',
|
'backup_failure_webhook_notifications',
|
||||||
'scheduled_task_success_webhook_notifications',
|
'scheduled_task_success_webhook_notifications',
|
||||||
'scheduled_task_failure_webhook_notifications',
|
'scheduled_task_failure_webhook_notifications',
|
||||||
|
'docker_cleanup_success_webhook_notifications',
|
||||||
|
'docker_cleanup_failure_webhook_notifications',
|
||||||
'server_disk_usage_webhook_notifications',
|
'server_disk_usage_webhook_notifications',
|
||||||
'server_reachable_webhook_notifications',
|
'server_reachable_webhook_notifications',
|
||||||
'server_unreachable_webhook_notifications',
|
'server_unreachable_webhook_notifications',
|
||||||
@@ -44,6 +46,8 @@ class WebhookNotificationSettings extends Model
|
|||||||
'backup_failure_webhook_notifications' => 'boolean',
|
'backup_failure_webhook_notifications' => 'boolean',
|
||||||
'scheduled_task_success_webhook_notifications' => 'boolean',
|
'scheduled_task_success_webhook_notifications' => 'boolean',
|
||||||
'scheduled_task_failure_webhook_notifications' => 'boolean',
|
'scheduled_task_failure_webhook_notifications' => 'boolean',
|
||||||
|
'docker_cleanup_success_webhook_notifications' => 'boolean',
|
||||||
|
'docker_cleanup_failure_webhook_notifications' => 'boolean',
|
||||||
'server_disk_usage_webhook_notifications' => 'boolean',
|
'server_disk_usage_webhook_notifications' => 'boolean',
|
||||||
'server_reachable_webhook_notifications' => 'boolean',
|
'server_reachable_webhook_notifications' => 'boolean',
|
||||||
'server_unreachable_webhook_notifications' => 'boolean',
|
'server_unreachable_webhook_notifications' => 'boolean',
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
use Illuminate\Database\Migrations\Migration;
|
use Illuminate\Database\Migrations\Migration;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
return new class extends Migration
|
return new class extends Migration
|
||||||
@@ -41,36 +42,35 @@ return new class extends Migration
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Populate webhook notification settings for existing teams (only if they don't already have settings)
|
// Populate webhook notification settings for existing teams (only if they don't already have settings)
|
||||||
$teams = DB::table('teams')->get();
|
DB::table('teams')->chunkById(100, function ($teams) {
|
||||||
|
foreach ($teams as $team) {
|
||||||
foreach ($teams as $team) {
|
try {
|
||||||
// Check if settings already exist for this team
|
DB::table('webhook_notification_settings')->updateOrInsert(
|
||||||
$exists = DB::table('webhook_notification_settings')
|
['team_id' => $team->id],
|
||||||
->where('team_id', $team->id)
|
[
|
||||||
->exists();
|
'webhook_enabled' => false,
|
||||||
|
'webhook_url' => null,
|
||||||
if (! $exists) {
|
'deployment_success_webhook_notifications' => false,
|
||||||
DB::table('webhook_notification_settings')->insert([
|
'deployment_failure_webhook_notifications' => true,
|
||||||
'team_id' => $team->id,
|
'status_change_webhook_notifications' => false,
|
||||||
'webhook_enabled' => false,
|
'backup_success_webhook_notifications' => false,
|
||||||
'webhook_url' => null,
|
'backup_failure_webhook_notifications' => true,
|
||||||
'deployment_success_webhook_notifications' => false,
|
'scheduled_task_success_webhook_notifications' => false,
|
||||||
'deployment_failure_webhook_notifications' => true,
|
'scheduled_task_failure_webhook_notifications' => true,
|
||||||
'status_change_webhook_notifications' => false,
|
'docker_cleanup_success_webhook_notifications' => false,
|
||||||
'backup_success_webhook_notifications' => false,
|
'docker_cleanup_failure_webhook_notifications' => true,
|
||||||
'backup_failure_webhook_notifications' => true,
|
'server_disk_usage_webhook_notifications' => true,
|
||||||
'scheduled_task_success_webhook_notifications' => false,
|
'server_reachable_webhook_notifications' => false,
|
||||||
'scheduled_task_failure_webhook_notifications' => true,
|
'server_unreachable_webhook_notifications' => true,
|
||||||
'docker_cleanup_success_webhook_notifications' => false,
|
'server_patch_webhook_notifications' => false,
|
||||||
'docker_cleanup_failure_webhook_notifications' => true,
|
'traefik_outdated_webhook_notifications' => true,
|
||||||
'server_disk_usage_webhook_notifications' => true,
|
]
|
||||||
'server_reachable_webhook_notifications' => false,
|
);
|
||||||
'server_unreachable_webhook_notifications' => true,
|
} catch (\Throwable $e) {
|
||||||
'server_patch_webhook_notifications' => false,
|
Log::error('Error creating webhook notification settings for team '.$team->id.': '.$e->getMessage());
|
||||||
'traefik_outdated_webhook_notifications' => true,
|
}
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user