fix: correct webhook notification settings migration and model
- Add missing traefik_outdated_webhook_notifications field to migration schema and population logic
- Remove incorrect docker_cleanup_webhook_notifications from model (split into success/failure variants)
- Consolidate webhook notification migrations from 2025_10_10 to 2025_11_25 for proper execution order
- Ensure all 15 notification fields are properly defined and consistent across migration, model, and Livewire component
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
17f4b126b1
commit
a3df33a4e0
6 changed files with 116 additions and 137 deletions
|
|
@ -24,7 +24,6 @@ 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_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',
|
||||||
|
|
@ -45,7 +44,6 @@ protected function casts(): array
|
||||||
'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_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',
|
||||||
|
|
|
||||||
|
|
@ -1,47 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
|
|
||||||
return new class extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*/
|
|
||||||
public function up(): void
|
|
||||||
{
|
|
||||||
$teams = DB::table('teams')->get();
|
|
||||||
|
|
||||||
foreach ($teams as $team) {
|
|
||||||
DB::table('webhook_notification_settings')->updateOrInsert(
|
|
||||||
['team_id' => $team->id],
|
|
||||||
[
|
|
||||||
'webhook_enabled' => false,
|
|
||||||
'webhook_url' => null,
|
|
||||||
'deployment_success_webhook_notifications' => false,
|
|
||||||
'deployment_failure_webhook_notifications' => true,
|
|
||||||
'status_change_webhook_notifications' => false,
|
|
||||||
'backup_success_webhook_notifications' => false,
|
|
||||||
'backup_failure_webhook_notifications' => true,
|
|
||||||
'scheduled_task_success_webhook_notifications' => false,
|
|
||||||
'scheduled_task_failure_webhook_notifications' => true,
|
|
||||||
'docker_cleanup_success_webhook_notifications' => false,
|
|
||||||
'docker_cleanup_failure_webhook_notifications' => true,
|
|
||||||
'server_disk_usage_webhook_notifications' => true,
|
|
||||||
'server_reachable_webhook_notifications' => false,
|
|
||||||
'server_unreachable_webhook_notifications' => true,
|
|
||||||
'server_patch_webhook_notifications' => false,
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*/
|
|
||||||
public function down(): void
|
|
||||||
{
|
|
||||||
// We don't need to do anything in down() since the webhook_notification_settings
|
|
||||||
// table will be dropped by the create migration's down() method
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
@ -1,36 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
|
|
||||||
return new class extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*/
|
|
||||||
public function up(): void
|
|
||||||
{
|
|
||||||
// Check if table already exists (handles upgrades from v444 where this migration
|
|
||||||
// was named 2025_10_10_120000_create_cloud_init_scripts_table.php)
|
|
||||||
if (Schema::hasTable('cloud_init_scripts')) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Schema::create('cloud_init_scripts', function (Blueprint $table) {
|
|
||||||
$table->id();
|
|
||||||
$table->foreignId('team_id')->constrained()->onDelete('cascade');
|
|
||||||
$table->string('name');
|
|
||||||
$table->text('script'); // Encrypted in the model
|
|
||||||
$table->timestamps();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*/
|
|
||||||
public function down(): void
|
|
||||||
{
|
|
||||||
Schema::dropIfExists('cloud_init_scripts');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
@ -1,52 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
|
|
||||||
return new class extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*/
|
|
||||||
public function up(): void
|
|
||||||
{
|
|
||||||
// Check if table already exists (handles upgrades from v444 where this migration
|
|
||||||
// was named 2025_10_10_120000_create_webhook_notification_settings_table.php)
|
|
||||||
if (Schema::hasTable('webhook_notification_settings')) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Schema::create('webhook_notification_settings', function (Blueprint $table) {
|
|
||||||
$table->id();
|
|
||||||
$table->foreignId('team_id')->constrained()->cascadeOnDelete();
|
|
||||||
|
|
||||||
$table->boolean('webhook_enabled')->default(false);
|
|
||||||
$table->text('webhook_url')->nullable();
|
|
||||||
|
|
||||||
$table->boolean('deployment_success_webhook_notifications')->default(false);
|
|
||||||
$table->boolean('deployment_failure_webhook_notifications')->default(true);
|
|
||||||
$table->boolean('status_change_webhook_notifications')->default(false);
|
|
||||||
$table->boolean('backup_success_webhook_notifications')->default(false);
|
|
||||||
$table->boolean('backup_failure_webhook_notifications')->default(true);
|
|
||||||
$table->boolean('scheduled_task_success_webhook_notifications')->default(false);
|
|
||||||
$table->boolean('scheduled_task_failure_webhook_notifications')->default(true);
|
|
||||||
$table->boolean('docker_cleanup_success_webhook_notifications')->default(false);
|
|
||||||
$table->boolean('docker_cleanup_failure_webhook_notifications')->default(true);
|
|
||||||
$table->boolean('server_disk_usage_webhook_notifications')->default(true);
|
|
||||||
$table->boolean('server_reachable_webhook_notifications')->default(false);
|
|
||||||
$table->boolean('server_unreachable_webhook_notifications')->default(true);
|
|
||||||
$table->boolean('server_patch_webhook_notifications')->default(false);
|
|
||||||
|
|
||||||
$table->unique(['team_id']);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*/
|
|
||||||
public function down(): void
|
|
||||||
{
|
|
||||||
Schema::dropIfExists('webhook_notification_settings');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
@ -0,0 +1,83 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
// Create table if it doesn't exist
|
||||||
|
if (! Schema::hasTable('webhook_notification_settings')) {
|
||||||
|
Schema::create('webhook_notification_settings', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('team_id')->constrained()->cascadeOnDelete();
|
||||||
|
|
||||||
|
$table->boolean('webhook_enabled')->default(false);
|
||||||
|
$table->text('webhook_url')->nullable();
|
||||||
|
|
||||||
|
$table->boolean('deployment_success_webhook_notifications')->default(false);
|
||||||
|
$table->boolean('deployment_failure_webhook_notifications')->default(true);
|
||||||
|
$table->boolean('status_change_webhook_notifications')->default(false);
|
||||||
|
$table->boolean('backup_success_webhook_notifications')->default(false);
|
||||||
|
$table->boolean('backup_failure_webhook_notifications')->default(true);
|
||||||
|
$table->boolean('scheduled_task_success_webhook_notifications')->default(false);
|
||||||
|
$table->boolean('scheduled_task_failure_webhook_notifications')->default(true);
|
||||||
|
$table->boolean('docker_cleanup_success_webhook_notifications')->default(false);
|
||||||
|
$table->boolean('docker_cleanup_failure_webhook_notifications')->default(true);
|
||||||
|
$table->boolean('server_disk_usage_webhook_notifications')->default(true);
|
||||||
|
$table->boolean('server_reachable_webhook_notifications')->default(false);
|
||||||
|
$table->boolean('server_unreachable_webhook_notifications')->default(true);
|
||||||
|
$table->boolean('server_patch_webhook_notifications')->default(false);
|
||||||
|
$table->boolean('traefik_outdated_webhook_notifications')->default(true);
|
||||||
|
|
||||||
|
$table->unique(['team_id']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Populate webhook notification settings for existing teams (only if they don't already have settings)
|
||||||
|
$teams = DB::table('teams')->get();
|
||||||
|
|
||||||
|
foreach ($teams as $team) {
|
||||||
|
// Check if settings already exist for this team
|
||||||
|
$exists = DB::table('webhook_notification_settings')
|
||||||
|
->where('team_id', $team->id)
|
||||||
|
->exists();
|
||||||
|
|
||||||
|
if (! $exists) {
|
||||||
|
DB::table('webhook_notification_settings')->insert([
|
||||||
|
'team_id' => $team->id,
|
||||||
|
'webhook_enabled' => false,
|
||||||
|
'webhook_url' => null,
|
||||||
|
'deployment_success_webhook_notifications' => false,
|
||||||
|
'deployment_failure_webhook_notifications' => true,
|
||||||
|
'status_change_webhook_notifications' => false,
|
||||||
|
'backup_success_webhook_notifications' => false,
|
||||||
|
'backup_failure_webhook_notifications' => true,
|
||||||
|
'scheduled_task_success_webhook_notifications' => false,
|
||||||
|
'scheduled_task_failure_webhook_notifications' => true,
|
||||||
|
'docker_cleanup_success_webhook_notifications' => false,
|
||||||
|
'docker_cleanup_failure_webhook_notifications' => true,
|
||||||
|
'server_disk_usage_webhook_notifications' => true,
|
||||||
|
'server_reachable_webhook_notifications' => false,
|
||||||
|
'server_unreachable_webhook_notifications' => true,
|
||||||
|
'server_patch_webhook_notifications' => false,
|
||||||
|
'traefik_outdated_webhook_notifications' => true,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('webhook_notification_settings');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
// Create table if it doesn't exist
|
||||||
|
if (! Schema::hasTable('cloud_init_scripts')) {
|
||||||
|
Schema::create('cloud_init_scripts', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('team_id')->constrained()->cascadeOnDelete();
|
||||||
|
$table->string('name');
|
||||||
|
$table->text('script'); // Encrypted in the model
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('cloud_init_scripts');
|
||||||
|
}
|
||||||
|
};
|
||||||
Loading…
Reference in a new issue