Add migration to fix webhook settings

This commit is contained in:
Marcus Moore
2025-05-20 12:27:19 -07:00
parent d6b69c8cc2
commit 13956254ce

View File

@@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
$settings = DB::table('settings')->first();
/** If webhook settings were cleared via the integration settings page,
* the webhook_selected was cleared as well when it should have reset to "slack".
*/
if (
empty($settings->webhook_selected) &&
(empty($settings->webhook_botname) && empty($settings->webhook_channel) && empty($settings->webhook_endpoint))
) {
DB::table('settings')->update(['webhook_selected' => 'slack']);
}
/** If webhook settings were cleared via the integration settings page,
* then slack settings were re-added; then webhook_selected was not being set to "slack" as needed.
*/
if (str_contains($settings->webhook_endpoint, 'slack.com')) {
DB::table('settings')->update(['webhook_selected' => 'slack']);
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
//
}
};